changeset 500:d3cd7d8d6b25 default tip

web: Breaking changes in flask-login API.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 07 Jun 2020 00:56:00 -0700
parents e75b39a762fd
children
files wikked/api/user.py wikked/auth.py wikked/views/__init__.py wikked/views/user.py
diffstat 4 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/wikked/api/user.py	Sun Jun 07 00:15:07 2020 -0700
+++ b/wikked/api/user.py	Sun Jun 07 00:56:00 2020 -0700
@@ -15,7 +15,7 @@
 
 @app.route('/api/user/is_logged_in')
 def api_user_is_logged_in():
-    if current_user.is_authenticated():
+    if current_user.is_authenticated:
         result = {'logged_in': True}
         return jsonify(result)
     abort(401)
@@ -31,7 +31,7 @@
 @app.route('/api/user/info')
 def api_current_user_info():
     user = current_user
-    if user.is_authenticated():
+    if user.is_authenticated:
         result = {
             'user': {
                 'username': user.username,
--- a/wikked/auth.py	Sun Jun 07 00:15:07 2020 -0700
+++ b/wikked/auth.py	Sun Jun 07 00:56:00 2020 -0700
@@ -67,12 +67,15 @@
         self.permissions = PERM_NONE
         self.groups = []
 
+    @property
     def is_authenticated(self):
         return True
 
+    @property
     def is_active(self):
         return True
 
+    @property
     def is_anonymous(self):
         return False
 
--- a/wikked/views/__init__.py	Sun Jun 07 00:15:07 2020 -0700
+++ b/wikked/views/__init__.py	Sun Jun 07 00:56:00 2020 -0700
@@ -7,7 +7,7 @@
 
 def add_auth_data(data):
     username = current_user.get_id()
-    if current_user.is_authenticated():
+    if current_user.is_authenticated:
         user_page_url = 'user:/%s' % urllib.parse.quote(username.title())
         data['auth'] = {
                 'is_logged_in': True,
--- a/wikked/views/user.py	Sun Jun 07 00:15:07 2020 -0700
+++ b/wikked/views/user.py	Sun Jun 07 00:56:00 2020 -0700
@@ -15,7 +15,7 @@
             raw_url='/api/user/login')
 
     if request.method == 'GET':
-        if current_user.is_authenticated():
+        if current_user.is_authenticated:
             data['already_logged_in'] = True
             return render_template('logout.html', **data)
         else: