Merge commit from fork

* Ensure tootctl revokes sessions, access tokens and web push subscriptions

* Fix test coverage
This commit is contained in:
Emelia Smith authored and GitHub committed 2025-10-13 14:20:23 +02:00
1 parent 8d09e4ef23
commit 24dcb18013
3 files changed
+25 -8

No files matched your search

+9 -4
View File
@@ -361,17 +361,22 @@ class User < ApplicationRecord
end
def reset_password!
# First, change password to something random, this revokes sessions and on-going access:
change_password!(SecureRandom.hex)
# Finally, send a reset password prompt to the user
send_reset_password_instructions
end
def change_password!(new_password)
# First, change password to something random and deactivate all sessions
transaction do
update(password: SecureRandom.hex)
update(password: new_password)
session_activations.destroy_all
end
# Then, remove all authorized applications and connected push subscriptions
revoke_access!
# Finally, send a reset password prompt to the user
send_reset_password_instructions
end
protected