From 58e121473b9f7e5127d175a87ab669b9011eafb6 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Tue, 17 Nov 2020 17:46:07 +0100 Subject: [PATCH] Fixed avatar URL --- flaschengeist/controller/userController.py | 8 ++++++-- flaschengeist/plugins/auth_ldap/__init__.py | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/flaschengeist/controller/userController.py b/flaschengeist/controller/userController.py index 275f1ff..96c52ab 100644 --- a/flaschengeist/controller/userController.py +++ b/flaschengeist/controller/userController.py @@ -1,4 +1,4 @@ -from flask import current_app +from flask import current_app, url_for from sqlalchemy.orm.exc import NoResultFound from werkzeug.exceptions import NotFound, BadRequest @@ -98,4 +98,8 @@ def load_avatar(user: User): def save_avatar(user, avatar): - return current_app.config["FG_AUTH_BACKEND"].set_avatar(user, avatar) + user.avatar_url = "" + r = current_app.config["FG_AUTH_BACKEND"].set_avatar(user, avatar) + if not user.avatar_url: + user.avatar_url = url_for('users.get_avatar', userid=user.userid) + db.session.commit() diff --git a/flaschengeist/plugins/auth_ldap/__init__.py b/flaschengeist/plugins/auth_ldap/__init__.py index d374597..1d22822 100644 --- a/flaschengeist/plugins/auth_ldap/__init__.py +++ b/flaschengeist/plugins/auth_ldap/__init__.py @@ -66,7 +66,6 @@ class AuthLDAP(AuthPlugin): user.lastname = r["sn"][0] if r["mail"]: user.mail = r["mail"][0] - user.avatar_url = f"/api/users/{user.userid}/avatar" if "displayName" in r: user.display_name = r["displayName"][0] userController.set_roles(user, self._get_groups(user.userid), create=True)