Skip to content

Commit

Permalink
datastore: fix evaluate user id
Browse files Browse the repository at this point in the history
  • Loading branch information
kpsherva committed Oct 10, 2023
1 parent fd668cb commit de7ed16
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion flask_security/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,20 @@ def __init__(self, db, user_model, role_model):
SQLAlchemyDatastore.__init__(self, db)
UserDatastore.__init__(self, user_model, role_model)

def _is_numeric(self, value):
try:
int(value)
except (TypeError, ValueError):
return False
return True

def get_user(self, identifier):
warnings.warn(
"get_user method is deprecated, user get_user_by_email/get_user_by_id",
DeprecationWarning
)
from sqlalchemy import func as alchemyFn
if isinstance(identifier, int):
if self._is_numeric(identifier):
return self.user_model.query.get(identifier)
for attr in get_identity_attributes():
query = alchemyFn.lower(getattr(self.user_model, attr)) \
Expand Down

0 comments on commit de7ed16

Please sign in to comment.