Class: Amalgam::SessionsController
Instance Method Summary
collapse
#default_url_options, #set_locale
amalgam_define_helpers
Instance Method Details
#create ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'app/controllers/amalgam/sessions_controller.rb', line 10
def create
@resource = build_resource(params)
@resource = @resource.class.authenticate params[resource_name][:login], params[resource_name][:password]
if @resource && @resource.admin?
session["#{resource_name}_id".to_sym] = @resource.id
redirect_back_or_default params[:return_to] || admin_root_url
else
if @resource
session["#{resource_name}_id".to_sym] = @resource.id
redirect_back_or_default params[:return_to] || Amalgam.authority_urls[resource_name.to_sym] || main_app.root_url
else
redirect_to eval("#{resource_name}_signin_url"), :alert => I18n.t('amalgam.sessions.fail.invalid_name_or_password')
end
end
end
|
#destroy ⇒ Object
26
27
28
29
|
# File 'app/controllers/amalgam/sessions_controller.rb', line 26
def destroy
session["#{params[:resource].to_s}_id".to_sym] = nil if params[:resource]
redirect_to main_app.root_url, :notice => I18n.t('amalgam.sessions.success.sign_out')
end
|
#new ⇒ Object
5
6
7
8
|
# File 'app/controllers/amalgam/sessions_controller.rb', line 5
def new
@name = params[:resource]
@resource = params[:resource].classify.safe_constantize.new
end
|