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
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!')
def clear_remember_token(user): database.delete('remember_token', user.remember_token)