Class: CustomerSessionController

Inherits:
Devise::SessionsController
  • Object
show all
Defined in:
lib/generators/ifd_tools/install/templates/controllers/customer_session_controller.rb

Instance Method Summary collapse

Instance Method Details

#after_sign_out_path_for(r) ⇒ Object



36
37
38
# File 'lib/generators/ifd_tools/install/templates/controllers/customer_session_controller.rb', line 36

def after_sign_out_path_for(r)
  root_path
end

#createObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/ifd_tools/install/templates/controllers/customer_session_controller.rb', line 3

def create
  @resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
  respond_to do |format|
    if @resource.banned?
      reset_session 
      format.json do
        render json: { response: 'failure', message: "Account has been suspended" }.to_json, status: :ok
      end
      format.html { redirect_to  root_path }
    elsif @resource.pending?
      reset_session 
      format.json do
        render json: { response: 'failure', message: "Account is pending approval" }.to_json, status: :ok
      end
      format.html { redirect_to  root_path }      
    else 
      set_flash_message(:notice, :signed_in) if is_navigational_format?
      result = (resource_name, @resource)
      format.json do
        render json: { response: 'success', auth_token: current_customer.authentication_token, first_name: current_customer.first_name, email: current_customer.email }.to_json, status: :ok
      end
      format.html do
        respond_with @resource, :location => redirect_location(resource_name, @resource)
      end
      format.xml
    end 
  end
end

#redirect_location(resource_name, resource) ⇒ Object



32
33
34
# File 'lib/generators/ifd_tools/install/templates/controllers/customer_session_controller.rb', line 32

def redirect_location(resource_name, resource)
  root_path
end