Skip to content

Commit

Permalink
FlaskPlugin: use get_id() instead of id attr
Browse files Browse the repository at this point in the history
Following Flask-Login documentation we should use current_user.get_id()
instead of current_user.id.  (closes #149)
https://flask-login.readthedocs.io/en/latest/#your-user-class

Signed-off-by: Jiri Kuncar <[email protected]>
  • Loading branch information
jirikuncar authored and marksteward committed Feb 10, 2022
1 parent 6c16fcd commit 9cc42a1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sqlalchemy_continuum/plugins/flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def fetch_current_user_id():
if _app_ctx_stack.top is None or _request_ctx_stack.top is None:
return
try:
return current_user.id
return current_user.get_id()
except AttributeError:
return

Expand Down
4 changes: 2 additions & 2 deletions tests/plugins/test_flask.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

from flask import Flask, url_for
from flask_login import LoginManager
from flask_login import LoginManager, UserMixin
from flask_sqlalchemy import SQLAlchemy, _SessionSignalEvents
from flexmock import flexmock

Expand Down Expand Up @@ -76,7 +76,7 @@ def logout(self, user=None):
def create_models(self):
TestCase.create_models(self)

class User(self.Model):
class User(self.Model, UserMixin):
__tablename__ = 'user'
__versioned__ = {
'base_classes': (self.Model, )
Expand Down

0 comments on commit 9cc42a1

Please sign in to comment.