Sha256: 81e62786de2ce76646e2bd31bca49102de7ac100c3929c413aec40d5d5161db1

Contents?: true

Size: 916 Bytes

Versions: 6

Compression:

Stored size: 916 Bytes

Contents

class Clearance::UsersController < ApplicationController
  skip_before_filter :authorize, :only => [:create, :new]
  before_filter :avoid_sign_in, :only => [:create, :new], :if => :signed_in?

  def new
    @user = user_from_params
    render :template => 'users/new'
  end

  def create
    @user = user_from_params

    if @user.save
      sign_in @user
      redirect_back_or url_after_create
    else
      render :template => 'users/new'
    end
  end

  private

  def avoid_sign_in
    redirect_to Clearance.configuration.redirect_url
  end

  def url_after_create
    Clearance.configuration.redirect_url
  end

  def user_from_params
    user_params = params[:user] || Hash.new
    email = user_params.delete(:email)
    password = user_params.delete(:password)

    Clearance.configuration.user_model.new(user_params).tap do |user|
      user.email = email
      user.password = password
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
clearance-1.2.0 app/controllers/clearance/users_controller.rb
clearance-1.1.0 app/controllers/clearance/users_controller.rb
clearance-1.0.1 app/controllers/clearance/users_controller.rb
clearance-1.0.0 app/controllers/clearance/users_controller.rb
clearance-1.0.0.rc8 app/controllers/clearance/users_controller.rb
clearance-1.0.0.rc7 app/controllers/clearance/users_controller.rb