forked from External/greenlight
Fixed signin bug
This commit is contained in:
parent
da80fb55c7
commit
2b9ab05e1e
|
@ -121,7 +121,7 @@ Metrics/ClassLength:
|
||||||
|
|
||||||
# Limit lines to 80 characters.
|
# Limit lines to 80 characters.
|
||||||
Metrics/LineLength:
|
Metrics/LineLength:
|
||||||
Max: 120
|
Max: 130
|
||||||
|
|
||||||
# Avoid methods longer than 10 lines of code.
|
# Avoid methods longer than 10 lines of code.
|
||||||
Metrics/MethodLength:
|
Metrics/MethodLength:
|
||||||
|
|
|
@ -63,17 +63,22 @@ class SessionsController < ApplicationController
|
||||||
def create
|
def create
|
||||||
logger.info "Support: #{session_params[:email]} is attempting to login."
|
logger.info "Support: #{session_params[:email]} is attempting to login."
|
||||||
|
|
||||||
user = User.include_deleted.find_by(email: session_params[:email], provider: @user_domain)
|
user = User.include_deleted.find_by(email: session_params[:email])
|
||||||
|
|
||||||
# Check user with that email exists
|
# Check user with that email exists
|
||||||
return redirect_to(signin_path, alert: I18n.t("invalid_credentials")) unless user
|
return redirect_to(signin_path, alert: I18n.t("invalid_credentials")) unless user
|
||||||
|
|
||||||
|
is_super_admin = user.has_role? :super_admin
|
||||||
|
|
||||||
|
# Scope user to domain if the user is not a super admin
|
||||||
|
user = User.include_deleted.find_by(email: session_params[:email], provider: @user_domain) unless is_super_admin
|
||||||
# Check correct password was entered
|
# Check correct password was entered
|
||||||
return redirect_to(signin_path, alert: I18n.t("invalid_credentials")) unless user.try(:authenticate,
|
return redirect_to(signin_path, alert: I18n.t("invalid_credentials")) unless user.try(:authenticate,
|
||||||
session_params[:password])
|
session_params[:password])
|
||||||
# Check that the user is not deleted
|
# Check that the user is not deleted
|
||||||
return redirect_to root_path, flash: { alert: I18n.t("registration.banned.fail") } if user.deleted?
|
return redirect_to root_path, flash: { alert: I18n.t("registration.banned.fail") } if user.deleted?
|
||||||
|
|
||||||
unless user.has_role? :super_admin
|
unless is_super_admin
|
||||||
# Check that the user is a Greenlight account
|
# Check that the user is a Greenlight account
|
||||||
return redirect_to(root_path, alert: I18n.t("invalid_login_method")) unless user.greenlight_account?
|
return redirect_to(root_path, alert: I18n.t("invalid_login_method")) unless user.greenlight_account?
|
||||||
# Check that the user has verified their account
|
# Check that the user has verified their account
|
||||||
|
|
Loading…
Reference in New Issue