All checks were successful
continuous-integration/drone/push Build is passing
32 lines
876 B
Python
32 lines
876 B
Python
#!/usr/bin/env python3
|
|
from sqlalchemy.sql import func
|
|
from flask_bcrypt import generate_password_hash, check_password_hash
|
|
|
|
from db import db
|
|
|
|
"""
|
|
Database models
|
|
"""
|
|
|
|
__author__ = '@tormakris'
|
|
__copyright__ = "Copyright 2020, videON Team"
|
|
__module_name__ = "models"
|
|
__version__text__ = "1"
|
|
|
|
|
|
class User(db.Model):
|
|
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
|
|
|
name = db.Column(db.String, nullable=False, unique=True)
|
|
password = db.Column(db.String, nullable=False)
|
|
|
|
last_logon = db.Column(db.TIMESTAMP, nullable=False, server_default=func.now())
|
|
|
|
timestamp = db.Column(db.TIMESTAMP, nullable=False, server_default=func.now())
|
|
|
|
def hash_password(self):
|
|
self.password = generate_password_hash(self.password).decode('utf8')
|
|
|
|
def check_password(self, password):
|
|
return check_password_hash(self.password, password)
|