[Plugin] auth_plain: Implemented Avatar

This commit is contained in:
Ferdinand Thiessen 2020-11-17 03:32:47 +01:00
parent 28865649b4
commit 88ff46c193
1 changed files with 9 additions and 1 deletions

View File

@ -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")