Force new password after password reset via API
This commit is contained in:
parent
fabdcf818b
commit
19dda1606b
3 changed files with 12 additions and 0 deletions
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Force new password after password reset via API
|
||||
merge_request:
|
||||
author: George Andrinopoulos
|
|
@ -160,6 +160,8 @@ module API
|
|||
end
|
||||
end
|
||||
|
||||
user_params.merge!(password_expires_at: Time.now) if user_params[:password].present?
|
||||
|
||||
if user.update_attributes(user_params.except(:extern_uid, :provider))
|
||||
present user, with: Entities::UserPublic
|
||||
else
|
||||
|
|
|
@ -305,6 +305,12 @@ describe API::Users, api: true do
|
|||
expect(user.reload.bio).to eq('new test bio')
|
||||
end
|
||||
|
||||
it "updates user with new password and forces reset on next login" do
|
||||
put api("/users/#{user.id}", admin), { password: '12345678' }
|
||||
expect(response).to have_http_status(200)
|
||||
expect(user.reload.password_expires_at).to be < Time.now
|
||||
end
|
||||
|
||||
it "updates user with organization" do
|
||||
put api("/users/#{user.id}", admin), { organization: 'GitLab' }
|
||||
|
||||
|
|
Loading…
Reference in a new issue