📜  python烧瓶模型用户 - Python代码示例

📅  最后修改于: 2022-03-11 14:47:02.086000             🧑  作者: Mango

代码示例1
from werkzeug.security import generate_password_hash, check_password_hash

class User(db.Model):
  id = db.Column(db.Integer, primary_key=True)
  username = db.Column(db.String(50), nullable=False, unique=True)
  password_hash = db.Column(db.String(255), nullable=False)
  
  def __init__(self, username):
    self.username = username
    
  def set_password(self, password):
    self.password_hash = generate_password_hash(password)
    
  def check_password(self, password):
    return check_password_hash(self.password_hash, password)