Force new password after password reset via API

This commit is contained in:
George Andrinopoulos 2017-02-02 12:46:14 +02:00
parent fabdcf818b
commit 19dda1606b
3 changed files with 12 additions and 0 deletions

View file

@ -0,0 +1,4 @@
---
title: Force new password after password reset via API
merge_request:
author: George Andrinopoulos

View file

@ -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

View file

@ -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' }