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 = sign_in(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
|