forked from gergely/calendar-social
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:
parent
943021e152
commit
c770e6cfa6
@ -76,7 +76,7 @@ class CalendarSocialApp(Flask):
|
|||||||
|
|
||||||
def __init__(self, name, config=None):
|
def __init__(self, name, config=None):
|
||||||
from .models import db, User, Role
|
from .models import db, User, Role
|
||||||
from .security import security
|
from .security import security, AnonymousUser
|
||||||
|
|
||||||
Flask.__init__(self, name)
|
Flask.__init__(self, name)
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ class CalendarSocialApp(Flask):
|
|||||||
babel.localeselector(get_locale)
|
babel.localeselector(get_locale)
|
||||||
|
|
||||||
user_store = SQLAlchemyUserDatastore(db, User, Role)
|
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)
|
self.context_processor(template_vars)
|
||||||
|
|
||||||
|
@ -17,6 +17,18 @@
|
|||||||
"""Security related things for Calendar.social
|
"""Security related things for Calendar.social
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from flask_security import Security
|
from flask_security import Security, AnonymousUser as BaseAnonymousUser
|
||||||
|
|
||||||
security = Security()
|
security = Security()
|
||||||
|
|
||||||
|
|
||||||
|
class AnonymousUser(BaseAnonymousUser):
|
||||||
|
"""Anonymous user class for Calendar.social
|
||||||
|
"""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def timezone(self):
|
||||||
|
"""The time zone of the anonymous user
|
||||||
|
"""
|
||||||
|
|
||||||
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user