-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
19 lines (15 loc) · 728 Bytes
/
Copy pathmodels.py
File metadata and controls
19 lines (15 loc) · 728 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from werkzeug.security import generate_password_hash, check_password_hash
from flask_login import UserMixin
from datetime import datetime
from db import db
class Usuario(UserMixin, db.Model):
__tablename__ = 'usuarios'
id = db.Column(db.Integer, primary_key=True)
data_criacao = db.Column(db.DateTime, default=datetime.now())
nome = db.Column(db.String(40), nullable=False, unique=True)
senha = db.Column(db.String, nullable=False)
funcao = db.Column(db.Integer, nullable=False, default=0)
def set_password(self, password):
self.senha = generate_password_hash(password)
def check_password(self, password):
return check_password_hash(self.senha, password)