我们从Python开源项目中,提取了以下18个代码示例,用于说明如何使用app.models.AnonymousUser()。
def verify_password(email_or_token, password): """Verify user using email and address or token, otherwise, set as anonymous user. """ if email_or_token == '': g.current_user = AnonymousUser() return True if password == '': g.current_user = User.verify_auth_token(email_or_token) g.token_used = True return g.current_user is not None user = User.query.filter_by(email=email_or_token).first() if not user: return False g.current_user = user g.token_used = False return user.verify_password(password)
def test_anonymous_user(self): u = AnonymousUser() self.assertFalse(u.can(Permission.FOLLOW))
def test_anonymous_user(self): u = AnonymousUser() self.assertFalse(u.operation(Permission.FOLLOW))
def test_anonymous_user(self): u = AnonymousUser() self.assertFalse(u.can(Permission.FOLLOW)) self.assertFalse(u.can(Permission.COMMENT)) self.assertFalse(u.can(Permission.WRITE)) self.assertFalse(u.can(Permission.MODERATE)) self.assertFalse(u.can(Permission.ADMIN))
def test_anonymous(self): u = AnonymousUser() self.assertFalse(u.can(Permission.GENERAL))
def verify_password(email_or_token, password): if email_or_token == '': g.current_user = AnonymousUser() return True if password == '': g.current_user = User.verify_auth_token(email_or_token) g.token_used = True return g.current_user is not None user = User.objects.filter(email=email_or_token) if not user: return False user = user.first_or_404() g.current_user = user g.token_used = False return user.verify_password(password)
def login_test(): if g.current_user == AnonymousUser(): return jsonify(status='error', data='Anonymous user!'), 401 else: return jsonify(email=g.current_user.email, status='success')