我有自定义管理类。使用HOw auth.login_required ...简单地使用@ auth.login_required作为装饰器没有帮助。我的代码段
class User(db.Model, BaseUser):
username = CharField()
password = CharField()
email = CharField(default='')
active = BooleanField(default=False)
#...other fields
def is_active(self):
return self.active
def is_anonymous(self):
return False
def is_authenticated(self):
return True
def __unicode__(self):
return self.username
class CustomAuth(Auth):
def get_user_model(self):
return User
def get_model_admin(self):
return UserAdmin
# instantiate custom auth
auth = CustomAuth(app, db, user_model=User)
@some_url.route('/some_url')
@auth.login_required # ITS NOT WORKIN
def some_url():
return "test url"
答案 0 :(得分:0)
试试这个
@some_url.route('/some_url')
@auth.login_required # ITS NOT WORKIN
def some_url():
user = auth.get_logged_in_user()
return "test url"