Skip to content

Commit

Permalink
Merged in r2-3139-signout-password-change-main (pull request #7008)
Browse files Browse the repository at this point in the history
R2-3139: Fixing issue where users get signed out after updating their password in profile
  • Loading branch information
jtoliver-quoin authored and pnabutovsky committed Dec 6, 2024
2 parents e092e59 + 05b27b9 commit 180289a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/api/v2/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def update
validate_json!(User::USER_FIELDS_SCHEMA, user_params)
@user.update_with_properties(@user_params)
@user.save!
keep_user_signed_in
end

def destroy
Expand Down Expand Up @@ -73,4 +74,8 @@ def welcome
def identity_sync
@user.identity_sync(current_user)
end

def keep_user_signed_in
bypass_sign_in(@user) if @user.saved_change_to_encrypted_password?
end
end
15 changes: 15 additions & 0 deletions spec/requests/api/v2/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,21 @@
expect(user1.identity_provider.unique_id).to eq(@identity_provider_b.unique_id)
end

it 'keeps user signed in when password changed' do
sign_in(@user_d)
params = {
data: {
password: 'primer0!',
password_confirmation: 'primer0!'
}
}
patch("/api/v2/users/#{@user_d.id}", params:)
expect(response).to have_http_status(200)
get('/api/v2/roles')
expect(response).to have_http_status(200)
expect(controller.current_user).to eq(@user_d)
end

it "returns 403 if user isn't authorized to update users" do
login_for_test
params = {
Expand Down

0 comments on commit 180289a

Please sign in to comment.