(feat): Stripped out all code that did the auth process
This commit is contained in:
parent
8148104e39
commit
4e2147e76c
1 changed files with 2 additions and 19 deletions
|
|
@ -1,25 +1,8 @@
|
||||||
from models import db, bcrypt
|
from models import db
|
||||||
|
|
||||||
class User(db.Model):
|
class User(db.Model):
|
||||||
__tablename__ = 'users'
|
__tablename__ = 'users'
|
||||||
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
username = db.Column(db.String(80), unique=True, nullable=False)
|
username = db.Column(db.String(80), unique=True, nullable=False)
|
||||||
password_hash = db.Column(db.String(128), nullable=False)
|
password = db.Column(db.String(128), nullable=False)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def create_user(username, password):
|
|
||||||
"""Create a new user with a hashed password"""
|
|
||||||
password_hash = bcrypt.generate_password_hash(password).decode('utf-8')
|
|
||||||
new_user = User(username=username, password_hash=password_hash)
|
|
||||||
db.session.add(new_user)
|
|
||||||
db.session.commit()
|
|
||||||
return new_user
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def verify_user(username, password):
|
|
||||||
"""Verify user creds"""
|
|
||||||
user = User.query.filter_by(username=username).first()
|
|
||||||
if user and bcrypt.check_password_hash(user.password_hash, password):
|
|
||||||
return user
|
|
||||||
return None
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue