Пример #1
0
def authenticate(state, code):
    r = get_reddit_oauth_session()
    if database.get('authentication_state', state) is None:
        raise AuthenticationFailure("Invalid state token")
    database.delete('authentication_state', state)
    access_information = r.get_access_information(code)
    authenticated_user = r.get_me()
    username = authenticated_user.name
    user = User(username)
    user.username = username
    update_access_information(user, access_information)
    database.save(user)
    login.set_remember_token(user)
    return user
Пример #2
0
def authenticate(state, code):
    r = get_reddit_oauth_session()
    if database.get('authentication_state', state) is None:
        raise AuthenticationFailure("Invalid state token")
    database.delete('authentication_state', state)
    access_information = r.get_access_information(code)
    authenticated_user = r.get_me()
    username = authenticated_user.name
    user = User(username)
    user.username = username
    update_access_information(user, access_information)
    database.save(user)
    login.set_remember_token(user)
    return user
Пример #3
0
 def test_delete(self, get_mock_db):
     mock_db = get_mock_db()
     database.delete('subscriptions', 'Kerrang!')
     mock_db.delete.assert_called_once_with('subscriptions:Kerrang!')
Пример #4
0
 def test_delete(self, get_mock_db):
     mock_db = get_mock_db()
     database.delete('subscriptions', 'Kerrang!')
     mock_db.delete.assert_called_once_with('subscriptions:Kerrang!')
Пример #5
0
def clear_remember_token(user):
    database.delete('remember_token', user.remember_token)
Пример #6
0
def clear_remember_token(user):
    database.delete('remember_token', user.remember_token)