class Agenda::UsersController < AgendaController
  respond_to :html
  before_filter :initialize_breadcrumb

  def new
    @user = User.new
  end

  def create
    role = Role.where(name: 'Invitado').first_or_create
    @user = User.new(params[:user])
    @user.role_id = role.try(:id)
    if @user.save
      sign_in(:user, @user)
      redirect_to root_path and return
    else
      render :new
    end
  end

  private
    def initialize_breadcrumb
      add_breadcrumb I18n.t('agenda.layout.home'), www_root_path
      add_breadcrumb 'Registrarse', ''
    end
end
