Sec.py 1.2 KB
Newer Older
Deamos's avatar
Deamos committed
1
from flask_security.forms import RegisterForm, StringField, Required,ConfirmRegisterForm,ForgotPasswordForm
Deamos's avatar
Deamos committed
2
from flask_security import UserMixin, RoleMixin
3
from shared import db
Deamos's avatar
Deamos committed
4 5 6 7

class ExtendedRegisterForm(RegisterForm):
    username = StringField('username', [Required()])

Deamos's avatar
Deamos committed
8 9 10
class ExtendedConfirmRegisterForm(ConfirmRegisterForm):
    username = StringField('username', [Required()])

Deamos's avatar
Deamos committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
roles_users = db.Table('roles_users',
        db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
        db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))

class Role(db.Model, RoleMixin):
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(80), unique=True)
    description = db.Column(db.String(255))

class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(255), unique=True)
    email = db.Column(db.String(255), unique=True)
    password = db.Column(db.String(255))
    active = db.Column(db.Boolean())
    confirmed_at = db.Column(db.DateTime())
    pictureLocation = db.Column(db.String(255))
    roles = db.relationship('Role', secondary=roles_users,
                            backref=db.backref('users', lazy='dynamic'))