From 8009fbaaaf8d014e8b3e8d283921b5bfe0d87485 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 12 Feb 2024 15:56:21 +0100 Subject: [PATCH] change password from shell --- idhub_auth/models.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/idhub_auth/models.py b/idhub_auth/models.py index e89bc35..ca4b422 100644 --- a/idhub_auth/models.py +++ b/idhub_auth/models.py @@ -155,3 +155,11 @@ class User(AbstractBaseUser): pw = base64.b64decode(password.encode('utf-8')*4) sb_key = self.derive_key_from_password(pw) return nacl.secret.SecretBox(sb_key) + + def change_password(self, old_password, new_password): + sensitive_data = self.decrypt_sensitive_data(old_password) + self.encrypted_sensitive_data = self.encrypt_sensitive_data( + new_password, + sensitive_data + ) + self.set_password(new_password)