Flask Login with Email instead of UserID

Implementing the timeout I was looking for an easy way to override the default behaviour in Flask which is to use the UserID field to login to a web app using Flask Login. I put together multiple different examples to get the following code: class User(UserMixin): def __init__(self, email, password): self.email = email self.password = password def get_id(self): return self.email This code overrides the default ‘User’ class in Flask Login, by extending the Usermixin object to define it’s own get_id method to return the email address, rather than a UserID....

March 12, 2023 · 2 min · Me