Create our own anonymous user class

This is required so the anonymous user also has a time zone (which is required to render public events.)
This commit is contained in:
Gergely Polonkai 2018-07-08 22:19:51 +02:00
parent 943021e152
commit c770e6cfa6
2 changed files with 15 additions and 3 deletions

View File

@ -76,7 +76,7 @@ class CalendarSocialApp(Flask):
def __init__(self, name, config=None):
from .models import db, User, Role
from .security import security
from .security import security, AnonymousUser
Flask.__init__(self, name)
@ -91,7 +91,7 @@ class CalendarSocialApp(Flask):
babel.localeselector(get_locale)
user_store = SQLAlchemyUserDatastore(db, User, Role)
security.init_app(self, datastore=user_store)
security.init_app(self, datastore=user_store, anonymous_user=AnonymousUser)
self.context_processor(template_vars)

View File

@ -17,6 +17,18 @@
"""Security related things for Calendar.social
"""
from flask_security import Security
from flask_security import Security, AnonymousUser as BaseAnonymousUser
security = Security()
class AnonymousUser(BaseAnonymousUser):
"""Anonymous user class for Calendar.social
"""
@property
def timezone(self):
"""The time zone of the anonymous user
"""
return None