Module: EasyAuth::Controllers::Sessions
- Extended by:
- ActiveSupport::Concern
- Included in:
- SessionsController
- Defined in:
- lib/easy_auth/controllers/sessions.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
71
72
73
74
75
76
|
# File 'lib/easy_auth/controllers/sessions.rb', line 71
def method_missing(method_name, *args)
unless method_name.to_s =~ /after_\w+_with_\w+/
super
end
end
|
Instance Method Details
#after_failed_sign_in ⇒ Object
36
37
38
|
# File 'lib/easy_auth/controllers/sessions.rb', line 36
def after_failed_sign_in
after_with_or_default(__method__)
end
|
#after_failed_sign_in_default ⇒ Object
48
49
50
51
|
# File 'lib/easy_auth/controllers/sessions.rb', line 48
def after_failed_sign_in_default
flash.now[:error] = I18n.t('easy_auth.sessions.create.error')
render :new
end
|
#after_sign_out ⇒ Object
53
54
55
|
# File 'lib/easy_auth/controllers/sessions.rb', line 53
def after_sign_out
redirect_to after_sign_out_url, :notice => I18n.t('easy_auth.sessions.delete.notice')
end
|
#after_sign_out_url ⇒ Object
57
58
59
|
# File 'lib/easy_auth/controllers/sessions.rb', line 57
def after_sign_out_url
main_app.root_url
end
|
#after_successful_sign_in ⇒ Object
28
29
30
|
# File 'lib/easy_auth/controllers/sessions.rb', line 28
def after_successful_sign_in
after_with_or_default(__method__)
end
|
#after_successful_sign_in_default ⇒ Object
40
41
42
|
# File 'lib/easy_auth/controllers/sessions.rb', line 40
def after_successful_sign_in_default
redirect_to(session.delete(:requested_path) || after_successful_sign_in_url, :notice => I18n.t('easy_auth.sessions.create.notice'))
end
|
#after_successful_sign_in_url ⇒ Object
32
33
34
|
# File 'lib/easy_auth/controllers/sessions.rb', line 32
def after_successful_sign_in_url
after_with_or_default(__method__)
end
|
#after_successful_sign_in_url_default ⇒ Object
44
45
46
|
# File 'lib/easy_auth/controllers/sessions.rb', line 44
def after_successful_sign_in_url_default
@identity.account
end
|
#after_with_or_default(method_name) ⇒ Object
24
25
26
|
# File 'lib/easy_auth/controllers/sessions.rb', line 24
def after_with_or_default(method_name)
send("#{method_name}_with_#{params[:identity]}") || send("#{method_name}_default")
end
|
#create ⇒ Object
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/easy_auth/controllers/sessions.rb', line 8
def create
if @identity = EasyAuth.authenticate(self)
session[:identity_id] = @identity.id
after_successful_sign_in
else
@identity = EasyAuth.find_identity_model(params).new(params[params[:identity]])
after_failed_sign_in
end
rescue AbstractController::DoubleRenderError
end
|
#destroy ⇒ Object
19
20
21
22
|
# File 'lib/easy_auth/controllers/sessions.rb', line 19
def destroy
session.delete(:identity_id)
after_sign_out
end
|
#new ⇒ Object
4
5
6
|
# File 'lib/easy_auth/controllers/sessions.rb', line 4
def new
EasyAuth.new_session(self)
end
|
#no_authentication ⇒ Object
61
62
63
64
65
|
# File 'lib/easy_auth/controllers/sessions.rb', line 61
def no_authentication
if account_signed_in?
redirect_to no_authentication_url
end
end
|
#no_authentication_url ⇒ Object
67
68
69
|
# File 'lib/easy_auth/controllers/sessions.rb', line 67
def no_authentication_url
main_app.root_url
end
|