网站后端.Flask.实战-社交博客开发-赋予角色?
1.用户在注册时,会被赋予适当的角色,管理员可通过FLASK_ADMIN全局变量中的邮件地址识别,其它用户使用默认角色 FlaskWeb/app/models.py #!/usr/bin/env python # -*- coding: utf-8 -*- """ # # Authors: limanman # OsChina: http://my.oschina.net/pydevops/ # Purpose: # """ from . import db, loginmanager from flask import current_app from flask_login import UserMixin from itsdangerous import TimedJSONWebSignatureSerializer as Serializer from werkzeug.security import generate_password_hash, check_password_hash @loginmanager.user_loader def load_user(user_id): return User.query.get(int(user_id)) class Permission(object): FOLLOW = 0x01 COMMENT = 0x02