Skip to content

Commit

Permalink
Merge pull request #13612 from opf/bug/49836-activate-accounts-on-pas…
Browse files Browse the repository at this point in the history
…sword-reset

[#49836] Activate users upon successful password reset
  • Loading branch information
aaron-contreras committed Sep 4, 2023
2 parents ed6e875 + 3336951 commit b96922a
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 148 deletions.
8 changes: 8 additions & 0 deletions app/services/users/change_password_service.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
Expand Down Expand Up @@ -40,9 +42,11 @@ def call(params)
current_user.password = params[:new_password]
current_user.password_confirmation = params[:new_password_confirmation]
current_user.force_password_change = false
current_user.activate if current_user.invited?

if current_user.save
invalidate_recovery_tokens
invalidate_invitation_tokens

log_success
::ServiceResult.new success: true,
Expand All @@ -64,6 +68,10 @@ def invalidate_recovery_tokens
Token::Recovery.where(user: current_user).delete_all
end

def invalidate_invitation_tokens
Token::Invitation.where(user: current_user).delete_all
end

def invalidate_session_result
update_message = I18n.t(:notice_account_password_updated)

Expand Down

0 comments on commit b96922a

Please sign in to comment.