add alert for account is locked
This commit is contained in:
parent
0ed9c4cbd4
commit
9438f962c5
2 changed files with 18 additions and 10 deletions
|
@ -15,9 +15,14 @@ class Users::SessionsController < Sessions::SessionsController
|
|||
# POST /resource/sign_in
|
||||
def create
|
||||
remember_me = params[:user][:remember_me] == '1'
|
||||
try_to_authenticate(User, remember_me)
|
||||
try_to_authenticate(Gestionnaire, remember_me)
|
||||
try_to_authenticate(Administrateur, remember_me)
|
||||
|
||||
if resource_locked?(try_to_authenticate(User, remember_me)) ||
|
||||
resource_locked?(try_to_authenticate(Gestionnaire, remember_me)) ||
|
||||
resource_locked?(try_to_authenticate(Administrateur, remember_me))
|
||||
flash.alert = 'Votre compte est verrouillé.'
|
||||
new
|
||||
return render :new, status: 401
|
||||
end
|
||||
|
||||
if user_signed_in?
|
||||
current_user.update(loged_in_with_france_connect: nil)
|
||||
|
@ -103,13 +108,16 @@ class Users::SessionsController < Sessions::SessionsController
|
|||
resource = klass.find_for_database_authentication(email: params[:user][:email])
|
||||
|
||||
if resource.present?
|
||||
if resource.access_locked?
|
||||
if resource.valid_password?(params[:user][:password])
|
||||
resource.remember_me = remember_me
|
||||
sign_in resource
|
||||
resource.force_sync_credentials
|
||||
end
|
||||
end
|
||||
end
|
||||
resource
|
||||
end
|
||||
|
||||
def resource_locked?(resource)
|
||||
resource.present? && resource.access_locked?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue