Skip to content

Commit

Permalink
Sessions controller returns account locked message when account is lo…
Browse files Browse the repository at this point in the history
…cked
  • Loading branch information
TylerRockwell committed Feb 20, 2018
1 parent 1e2a772 commit 87a1d6e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion app/controllers/devise_token_auth/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ def create

render_create_success
elsif @resource && !(!@resource.respond_to?(:active_for_authentication?) || @resource.active_for_authentication?)
render_create_error_not_confirmed
if @resource.respond_to?(:locked_at) && @resource.locked_at
render_create_error_account_locked
else
render_create_error_not_confirmed
end
else
render_create_error_bad_credentials
end
Expand Down Expand Up @@ -102,6 +106,10 @@ def render_create_error_not_confirmed
render_error(401, I18n.t("devise_token_auth.sessions.not_confirmed", email: @resource.email))
end

def render_create_error_account_locked
render_error(401, I18n.t("devise.mailer.unlock_instructions.account_lock_msg"))
end

def render_create_error_bad_credentials
render_error(401, I18n.t("devise_token_auth.sessions.bad_credentials"))
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def @controller.reset_session

test 'response should contain errors' do
assert @data['errors']
assert_equal @data['errors'], [I18n.t('devise_token_auth.sessions.not_confirmed', email: @locked_user.email)]
assert_equal @data['errors'], [I18n.t('devise.mailer.unlock_instructions.account_lock_msg')]
end
end

Expand Down

0 comments on commit 87a1d6e

Please sign in to comment.