Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Flask security login with correct user id #862

Open
earnestman opened this issue Jun 10, 2020 · 3 comments
Open

Flask security login with correct user id #862

earnestman opened this issue Jun 10, 2020 · 3 comments

Comments

@earnestman
Copy link

Hi
I use flask security, everything is fine but i can login with correct user id and password!
But i want to login only with correct username and password

@radusuciu
Copy link

radusuciu commented Jul 16, 2020

What datastore are you using? My guess is code like this is responsible: https://github.com/mattupstate/flask-security/blob/develop/flask_security/datastore.py#L242-L249

if self._is_numeric(identifier):
    return user_model_query.get(identifier)
for attr in get_identity_attributes():
    query = alchemyFn.lower(getattr(self.user_model, attr)) \
        == alchemyFn.lower(identifier)
    rv = user_model_query.filter(query).first()
    if rv is not None:
        return rv

@manganmus
Copy link

I have the same problem - when trying to login (or register a new user), I get "Model.UserDoesNotExist - instance matching query does not exist" . Debug message shows the query is filtering on user.id = the email address given in get_user(). I'm using Peewee for the datastore. Is there a fix for this?

@jwag956
Copy link
Collaborator

jwag956 commented Sep 21, 2020

I am not sure in 3.0.0 - but in my fork - this should be fixed in 3.4.4:
https://pypi.org/project/Flask-Security-Too/

If you try Flask-Security-Too - make sure you follow the quick start guide - in particular:

    # we need the one from UserMixin.
    class User(UserMixin, db.Model):

i.e. the order of inheritence/mixin is important.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants