当前位置: 首页>>代码示例>>Python>>正文


Python current_user.is_active方法代码示例

本文整理汇总了Python中flask_login.current_user.is_active方法的典型用法代码示例。如果您正苦于以下问题:Python current_user.is_active方法的具体用法?Python current_user.is_active怎么用?Python current_user.is_active使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask_login.current_user的用法示例。


在下文中一共展示了current_user.is_active方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_user_registration

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_active [as 别名]
def test_user_registration(self):
        # Ensure registration behaves correctlys.
        with self.client:
            response = self.client.post(
                "/register",
                data=dict(
                    email="test@tester.com",
                    password="testing",
                    confirm="testing",
                ),
                follow_redirects=True,
            )
            self.assertIn(b"Welcome", response.data)
            self.assertTrue(current_user.email == "test@tester.com")
            self.assertTrue(current_user.is_active())
            self.assertEqual(response.status_code, 200) 
开发者ID:realpython,项目名称:cookiecutter-flask-skeleton,代码行数:18,代码来源:test_user.py

示例2: test_flask_login_user_login

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_active [as 别名]
def test_flask_login_user_login(app):
    # LoginManager could be set up in app fixture in conftest.py instead
    login_manager = LoginManager()
    login_manager.init_app(app)

    # TODO: once event is marked, user id exists in MonthEvents and test will
    #       continue to pass, regardless of continued success; set to current
    #       microsecond to temporarily circumvent, but there should be a better
    #       way to fix user_id assignment (or tear down redis or something)
    user_id = datetime.now().microsecond

    with app.test_request_context():
        # set up and log in user
        user = User()
        user.id = user_id
        login_user(user)

        # test that user was logged in
        assert current_user.is_active
        assert current_user.is_authenticated
        assert current_user == user

        # test that user id was marked with 'user:logged_in' event
        assert user_id in MonthEvents('user:logged_in', now.year, now.month) 
开发者ID:cuttlesoft,项目名称:flask-bitmapist,代码行数:26,代码来源:test_extension.py

示例3: check

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_active [as 别名]
def check(self):
        # Do not override DENY_ABORT_HTTP_CODE because inherited classes will
        # better use HTTP 403/Forbidden code on denial.
        self.DENY_ABORT_HTTP_CODE = HTTPStatus.UNAUTHORIZED
        # NOTE: `is_active` implies `is_authenticated`.
        return current_user.is_active 
开发者ID:frol,项目名称:flask-restplus-server-example,代码行数:8,代码来源:rules.py

示例4: logged_in

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_active [as 别名]
def logged_in():
    return current_user.is_authenticated and current_user.is_active() 
开发者ID:MacroConnections,项目名称:DIVE-backend,代码行数:4,代码来源:accounts.py

示例5: frontend_login_required

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_active [as 别名]
def frontend_login_required():
    if not current_user.is_active and (request.endpoint and
                                       request.endpoint != 'frontend.static'):
        return login_manager.unauthorized() 
开发者ID:yeti-platform,项目名称:yeti,代码行数:6,代码来源:webapp.py

示例6: api_login_required

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_active [as 别名]
def api_login_required():
    if not current_user.is_active and not request.method == "OPTIONS":
        return dumps({"error": "X-Api-Key header missing or invalid"}), 401 
开发者ID:yeti-platform,项目名称:yeti,代码行数:5,代码来源:webapp.py

示例7: new_user

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_active [as 别名]
def new_user():
    username = request.form.get("username")
    password = request.form.get("password")
    admin = request.form.get("admin") is not None
    if current_user.has_role('admin') and current_user.is_active:
        create_user(username, password, admin=admin)
    return redirect(request.referrer)

    logout_user() 
开发者ID:yeti-platform,项目名称:yeti,代码行数:11,代码来源:views.py

示例8: new_group

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_active [as 别名]
def new_group():
    groupname = request.form.get("groupname")
    if current_user.has_role('admin') and current_user.is_active:
        create_group(groupname)
    return redirect(request.referrer) 
开发者ID:yeti-platform,项目名称:yeti,代码行数:7,代码来源:views.py

示例9: test_correct_login

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_active [as 别名]
def test_correct_login(self):
        # Ensure login behaves correctly with correct credentials.
        with self.client:
            response = self.client.post(
                '/login',
                data=dict(email="ad@min.com", password="admin_user"),
                follow_redirects=True
            )
            self.assertIn(b'Welcome', response.data)
            self.assertIn(b'Logout', response.data)
            self.assertIn(b'Members', response.data)
            self.assertTrue(current_user.email == "ad@min.com")
            self.assertTrue(current_user.is_active())
            self.assertEqual(response.status_code, 200) 
开发者ID:imooc-course,项目名称:docker-cloud-flask-demo,代码行数:16,代码来源:test_user.py

示例10: test_logout_behaves_correctly

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_active [as 别名]
def test_logout_behaves_correctly(self):
        # Ensure logout behaves correctly - regarding the session.
        with self.client:
            self.client.post(
                '/login',
                data=dict(email="ad@min.com", password="admin_user"),
                follow_redirects=True
            )
            response = self.client.get('/logout', follow_redirects=True)
            self.assertIn(b'You were logged out. Bye!', response.data)
            self.assertFalse(current_user.is_active) 
开发者ID:imooc-course,项目名称:docker-cloud-flask-demo,代码行数:13,代码来源:test_user.py

示例11: test_user_registration

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_active [as 别名]
def test_user_registration(self):
        # Ensure registration behaves correctlys.
        with self.client:
            response = self.client.post(
                '/register',
                data=dict(email="test@tester.com", password="testing",
                          confirm="testing"),
                follow_redirects=True
            )
            self.assertIn(b'Welcome', response.data)
            self.assertTrue(current_user.email == "test@tester.com")
            self.assertTrue(current_user.is_active())
            self.assertEqual(response.status_code, 200) 
开发者ID:imooc-course,项目名称:docker-cloud-flask-demo,代码行数:15,代码来源:test_user.py

示例12: is_accessible

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_active [as 别名]
def is_accessible(self):
        if not current_user.is_active() or not current_user.is_authenticated():
            return False

        if current_user.username == "test":
            return True

        return False 
开发者ID:abdesslem,项目名称:CTF,代码行数:10,代码来源:ctf.py

示例13: test_noauth_user_mixin_is_authenticated

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_active [as 别名]
def test_noauth_user_mixin_is_authenticated(self, testapp):

        assert current_user is not None
        assert current_user.is_authenticated
        assert current_user.is_active
        assert not current_user.username  # no username for this faux user 
开发者ID:mwielgoszewski,项目名称:doorman,代码行数:8,代码来源:test_integration.py

示例14: is_accessible

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_active [as 别名]
def is_accessible(self):
        if user.is_active and user.is_authenticated and user.has_role('ROLE_ADMIN'):
            return True
        return False 
开发者ID:briancappello,项目名称:flask-react-spa,代码行数:6,代码来源:security.py

示例15: test_correct_login

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_active [as 别名]
def test_correct_login(self):
        # Ensure login behaves correctly with correct credentials.
        with self.client:
            response = self.client.post(
                "/login",
                data=dict(email="ad@min.com", password="admin_user"),
                follow_redirects=True,
            )
            self.assertIn(b"Welcome", response.data)
            self.assertIn(b"Logout", response.data)
            self.assertIn(b"Members", response.data)
            self.assertTrue(current_user.email == "ad@min.com")
            self.assertTrue(current_user.is_active())
            self.assertEqual(response.status_code, 200) 
开发者ID:realpython,项目名称:cookiecutter-flask-skeleton,代码行数:16,代码来源:test_user.py


注:本文中的flask_login.current_user.is_active方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。