Fixed avatar URL

This commit is contained in:
Ferdinand Thiessen 2020-11-17 17:46:07 +01:00
parent 88ff46c193
commit 58e121473b
2 changed files with 6 additions and 3 deletions

View File

@ -1,4 +1,4 @@
from flask import current_app from flask import current_app, url_for
from sqlalchemy.orm.exc import NoResultFound from sqlalchemy.orm.exc import NoResultFound
from werkzeug.exceptions import NotFound, BadRequest from werkzeug.exceptions import NotFound, BadRequest
@ -98,4 +98,8 @@ def load_avatar(user: User):
def save_avatar(user, avatar): 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()

View File

@ -66,7 +66,6 @@ class AuthLDAP(AuthPlugin):
user.lastname = r["sn"][0] user.lastname = r["sn"][0]
if r["mail"]: if r["mail"]:
user.mail = r["mail"][0] user.mail = r["mail"][0]
user.avatar_url = f"/api/users/{user.userid}/avatar"
if "displayName" in r: if "displayName" in r:
user.display_name = r["displayName"][0] user.display_name = r["displayName"][0]
userController.set_roles(user, self._get_groups(user.userid), create=True) userController.set_roles(user, self._get_groups(user.userid), create=True)