From ea12bdb3f874c32805e0e8000037c8c57ff64282 Mon Sep 17 00:00:00 2001
From: Sotiris Tsepelakis <sotirios.tsepelakis@tuwien.ac.at>
Date: Thu, 27 Apr 2023 17:30:26 +0200
Subject: [PATCH] Add "TU Wien" affiliation to user profile
* Currently only people from TUW can sign-in, which is why the value is hard-coded.
* Closes #4
---
invenio_config_tuw/auth/handlers.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/invenio_config_tuw/auth/handlers.py b/invenio_config_tuw/auth/handlers.py
index cb6bea2..764fc98 100644
--- a/invenio_config_tuw/auth/handlers.py
+++ b/invenio_config_tuw/auth/handlers.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2020-2022 TU Wien.
+# Copyright (C) 2020-2023 TU Wien.
#
-# Invenio-Config-TUW is free software; you can redistribute it and/or modify
+# Invenio Config TUW is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
"""Custom handlers for the Keycloak integration."""
@@ -214,6 +214,10 @@ def base_authorized_signup_handler(resp, remote, *args, **kwargs):
if new_full_name and new_full_name != user.user_profile["full_name"]:
user.user_profile = {"full_name": new_full_name, **old_profile}
+ # Hard code the affiliation to TU Wien, since we are currently not accepting any externals.
+ # It is set on every login.
+ user.user_profile = {**user.user_profile, "affiliations": "TU Wien"}
+
# Link account
# ------------
# Need to store token in database instead of only the session when
--
GitLab