From 554f69574cf2e858321daf017b755128d195789d Mon Sep 17 00:00:00 2001 From: Julian B Date: Wed, 11 Oct 2023 16:11:02 +0200 Subject: [PATCH 1/3] do not update users from OIDC --- myhpi/core/auth.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/myhpi/core/auth.py b/myhpi/core/auth.py index 29d07219..9953bc4a 100644 --- a/myhpi/core/auth.py +++ b/myhpi/core/auth.py @@ -32,15 +32,6 @@ def create_user(self, claims): return user - def update_user(self, user, claims): - user.first_name = claims.get("given_name", "") - user.last_name = claims.get("family_name", "") - user.email = mail_replacement(claims.get("email")) - - user.save() - - return user - def filter_users_by_claims(self, claims): """Return all users matching the specified username.""" username = claims.get("sub") From fb47970477a7515f49fd6902cd6e17b8b9e59dab Mon Sep 17 00:00:00 2001 From: Julian B Date: Wed, 18 Oct 2023 21:55:47 +0200 Subject: [PATCH 2/3] update email again --- myhpi/core/auth.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/myhpi/core/auth.py b/myhpi/core/auth.py index 9953bc4a..a3cf975a 100644 --- a/myhpi/core/auth.py +++ b/myhpi/core/auth.py @@ -32,6 +32,12 @@ def create_user(self, claims): return user + def update_user(self, user, claims): + user.email = mail_replacement(claims.get("email")) + user.save() + + return user + def filter_users_by_claims(self, claims): """Return all users matching the specified username.""" username = claims.get("sub") From 7c0dcd6acd43d2132c7285495b5c89784d4db765 Mon Sep 17 00:00:00 2001 From: Julian B Date: Thu, 19 Oct 2023 16:13:33 +0200 Subject: [PATCH 3/3] fix tests --- myhpi/tests/core/test_auth.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/myhpi/tests/core/test_auth.py b/myhpi/tests/core/test_auth.py index d81e7b4b..63998d40 100644 --- a/myhpi/tests/core/test_auth.py +++ b/myhpi/tests/core/test_auth.py @@ -44,6 +44,8 @@ def test_update_user(self): self.assertEqual(user.username, "jw.goethe") self.assertEqual(user.last_name, "Goethe") claims["family_name"] = "von Goethe" + claims["email"] = "jw.goethe@weimar.eu" user = self.auth_backend.update_user(user, claims) self.assertEqual(user.first_name, "Johann Wolfgang") - self.assertEqual(user.last_name, "von Goethe") + self.assertEqual(user.last_name, "Goethe") + self.assertEqual(user.email, "jw.goethe@weimar.eu")