From 88ff46c193593bb329c007fd3a0e9d410b86d6f5 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Tue, 17 Nov 2020 03:32:47 +0100 Subject: [PATCH] [Plugin] auth_plain: Implemented Avatar --- flaschengeist/plugins/auth_plain/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/flaschengeist/plugins/auth_plain/__init__.py b/flaschengeist/plugins/auth_plain/__init__.py index 49575e5..ce9d006 100644 --- a/flaschengeist/plugins/auth_plain/__init__.py +++ b/flaschengeist/plugins/auth_plain/__init__.py @@ -6,7 +6,7 @@ Flaschengeist database (as User attribute) import os import hashlib import binascii -from werkzeug.exceptions import BadRequest +from werkzeug.exceptions import BadRequest, NotFound from flaschengeist.plugins import AuthPlugin from flaschengeist.models.user import User @@ -33,6 +33,14 @@ class AuthPlain(AuthPlugin): def delete_user(self, user): pass + def get_avatar(self, user): + if not user.has_attribute("avatar"): + raise NotFound + return user.get_attribute("avatar") + + def set_avatar(self, user, avatar): + user.set_attribute("avatar", avatar) + @staticmethod def _hash_password(password): salt = hashlib.sha256(os.urandom(60)).hexdigest().encode("ascii")