Class: UserSessionsController

Inherits:
Devise::SessionsController
  • Object
show all
Includes:
Spree::CurrentOrder, SpreeBase
Defined in:
app/controllers/user_sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/user_sessions_controller.rb', line 16

def create
  authenticate_user!

  if user_signed_in?
    api_key = current_user.generate_api_key!
    user_response = Hash.new
    user_response[:user] = Hash.new
    user_response[:user][:email]=current_user.email
    user_response[:user][:authentication_token]=current_user.authentication_token
    user_response[:user][:sign_in_count]=current_user.
    respond_to do |format|
      format.html {
        flash.notice = t(:logged_in_succesfully)
        redirect_back_or_default(products_path)
      }
      format.json {
        render :json => user_response.to_json
      }
    end
  else
    flash.now[:error] = t('devise.failure.invalid')
    render :new
  end
end

#destroyObject

~ end



60
61
62
63
# File 'app/controllers/user_sessions_controller.rb', line 60

def destroy
  session.clear
  super
end


65
66
67
# File 'app/controllers/user_sessions_controller.rb', line 65

def nav_bar
  render :partial => "shared/nav_bar"
end

#newObject

GET /resource/sign_in



13
14
15
# File 'app/controllers/user_sessions_controller.rb', line 13

def new
  super
end