def authenticate_credentials(self, key): try: user = MultiToken.get_user_from_token(key) if user._type == 'DOC': user.lastseen = time.time() user.save() if settings.DJFORGE_REDIS_MULTITOKENS.get( 'RESET_TOKEN_TTL_ON_USER_LOG_IN'): MultiToken.reset_tokens_ttl(user.pk) except get_user_model().DoesNotExist: raise exceptions.AuthenticationFailed('Invalid token.') if not user.is_active: raise exceptions.AuthenticationFailed('User inactive or deleted.') return (user, MultiToken(key, user))
def test_correct_user_is_found_for_correct_token(self): user = MultiToken.get_user_from_token(self.token.key) self.assertEqual(user.pk, self.user.pk)