Class: Clearance::UsersController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/clearance/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#avoid_sign_inObject (private)


24
25
26
27
28
29
30
# File 'app/controllers/clearance/users_controller.rb', line 24

def 
  warn "[DEPRECATION] Clearance's `avoid_sign_in` before_filter is " +
    "deprecated. Use `redirect_signed_in_users` instead. " +
    "Be sure to update any instances of `skip_before_filter :avoid_sign_in`" +
    " or `skip_before_action :avoid_sign_in` as well"
  redirect_signed_in_users
end

#createObject


11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/clearance/users_controller.rb', line 11

def create
  @user = user_from_params

  if @user.save
     @user
    redirect_back_or url_after_create
  else
    render template: "users/new"
  end
end

#newObject


6
7
8
9
# File 'app/controllers/clearance/users_controller.rb', line 6

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

#redirect_signed_in_usersObject (private)


32
33
34
35
36
# File 'app/controllers/clearance/users_controller.rb', line 32

def redirect_signed_in_users
  if signed_in?
    redirect_to Clearance.configuration.redirect_url
  end
end

#url_after_createObject (private)


38
39
40
# File 'app/controllers/clearance/users_controller.rb', line 38

def url_after_create
  Clearance.configuration.redirect_url
end

#user_from_paramsObject (private)


42
43
44
45
46
47
48
49
50
# File 'app/controllers/clearance/users_controller.rb', line 42

def user_from_params
  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

#user_paramsObject (private)


52
53
54
# File 'app/controllers/clearance/users_controller.rb', line 52

def user_params
  params[:user] || Hash.new
end