forked from External/greenlight
Redirecting the user to the referrer on login success/fail (#374)
This commit is contained in:
committed by
Jesus Federico
parent
a0036e244b
commit
404134aa8d
@ -29,13 +29,19 @@ class SessionsController < ApplicationController
|
||||
def create
|
||||
user = User.find_by(email: session_params[:email])
|
||||
if user && !user.greenlight_account?
|
||||
redirect_to root_path, alert: I18n.t("invalid_login_method")
|
||||
if request.referrer.present?
|
||||
redirect_to request.referrer, alert: I18n.t("invalid_login_method")
|
||||
else
|
||||
redirect_to root_path, alert: I18n.t("invalid_login_method")
|
||||
end
|
||||
elsif user.try(:authenticate, session_params[:password])
|
||||
if user.email_verified
|
||||
login(user)
|
||||
else
|
||||
redirect_to(account_activation_path(email: user.email)) && return
|
||||
end
|
||||
elsif request.referrer.present?
|
||||
redirect_to request.referrer, alert: I18n.t("invalid_credentials")
|
||||
else
|
||||
redirect_to root_path, alert: I18n.t("invalid_credentials")
|
||||
end
|
||||
|
Reference in New Issue
Block a user