Class: SessionsController
Instance Method Summary
collapse
#error
#best_euros, #current_basket, #current_basket_or_nil, #current_clerk, #date, #euros, #has_ssl?, #markdown, #new_basket, #paginate, #shipping_method
Instance Method Details
#create ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'app/controllers/sessions_controller.rb', line 8
def create
clerk = Clerk.where(:email => params[:email]).limit(1).first
if clerk && clerk.valid_password?(params[:password])
session[:clerk_email] = clerk.email
if clerk.admin
redirect_to baskets_url , :notice => I18n.t(:signed_in)
else
redirect_after_sign_up
end
else
redirect_to sign_in_url , :notice => I18n.t(:sign_in_invalid)
end
end
|
#sign_in ⇒ Object
5
6
|
# File 'app/controllers/sessions_controller.rb', line 5
def sign_in
end
|
#sign_out ⇒ Object
22
23
24
25
|
# File 'app/controllers/sessions_controller.rb', line 22
def sign_out
session[:clerk_email] = nil
redirect_to Rails.application.routes.url_helpers.root_path , :notice => I18n.t(:signed_out)
end
|
#sign_up ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/controllers/sessions_controller.rb', line 27
def sign_up
if request.get?
@clerk = Clerk.new
else
@clerk = Clerk.new(params_for_clerk)
if @clerk.save
session[:clerk_email] = @clerk.email
return redirect_after_sign_up
end
end
end
|