[Plugin] auth_plain: Implemented Avatar
This commit is contained in:
parent
28865649b4
commit
88ff46c193
|
@ -6,7 +6,7 @@ Flaschengeist database (as User attribute)
|
||||||
import os
|
import os
|
||||||
import hashlib
|
import hashlib
|
||||||
import binascii
|
import binascii
|
||||||
from werkzeug.exceptions import BadRequest
|
from werkzeug.exceptions import BadRequest, NotFound
|
||||||
|
|
||||||
from flaschengeist.plugins import AuthPlugin
|
from flaschengeist.plugins import AuthPlugin
|
||||||
from flaschengeist.models.user import User
|
from flaschengeist.models.user import User
|
||||||
|
@ -33,6 +33,14 @@ class AuthPlain(AuthPlugin):
|
||||||
def delete_user(self, user):
|
def delete_user(self, user):
|
||||||
pass
|
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
|
@staticmethod
|
||||||
def _hash_password(password):
|
def _hash_password(password):
|
||||||
salt = hashlib.sha256(os.urandom(60)).hexdigest().encode("ascii")
|
salt = hashlib.sha256(os.urandom(60)).hexdigest().encode("ascii")
|
||||||
|
|
Loading…
Reference in New Issue