Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ExRx/login.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
17 lines (14 sloc)
443 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bcrypt | |
from exrx.database import User | |
from exrx import app | |
@app.login_manager.user_loader | |
def load_user(user_id): | |
return User.query.filter_by(id=int(user_id)).first() | |
def validate_and_get_user(username, password): | |
user = User.query.filter_by(username=username).first() | |
if(not user): | |
return None | |
if bcrypt.checkpw(bytes(password,"utf-8"), user.password_hash): | |
return user | |
else: | |
return None |