Пример #1
0
def index_view(context, request):
    username = request.session.get('username', '')
    result = {'username': username}
    if username == '':
        result['admin'] = False
    else:
        result['admin'] = True if 'group:admin' in User.by_username(username, request).groups else False
    return result
Пример #2
0
    def test_by_username(self):
        from papaye.models import User
        from papaye.factories import user_root_factory

        root = user_root_factory(self.request)
        root['a_user'] = User('a_user', 'password')

        result = User.by_username('a_user', self.request)

        self.assertIsInstance(result, User)
        self.assertEqual(result.username, 'a_user')
Пример #3
0
    def test_by_username(self):
        from papaye.models import User
        from papaye.factories import user_root_factory

        root = user_root_factory(self.request)
        root['a_user'] = User('a_user', 'password')

        result = User.by_username('a_user', self.request)

        self.assertIsInstance(result, User)
        self.assertEqual(result.username, 'a_user')
Пример #4
0
def auth_check_func(username, password, request):
    user = User.by_username(username, request)
    if user and user.password_verify(password):
        return user.groups
    return None
Пример #5
0
    def test_by_username_without_result(self):
        from papaye.models import User

        result = User.by_username('a_user', self.request)

        self.assertIsNone(result)
Пример #6
0
    def test_by_username_without_result(self):
        from papaye.models import User

        result = User.by_username('a_user', self.request)

        self.assertIsNone(result)
Пример #7
0
def auth_check_func(username, password, request):
    user = User.by_username(username, request)
    if user and user.password_verify(password):
        return user.groups
    return None