Example #1
0
def validate_password_token(request):
    args = PostParametersList(request)
    args.check_parameter(key='uid', required=True)
    args.check_parameter(key='token', required=True)
    user = PasswordToken.validate_token(args['uid'], args['token'])

    if user is None:
        raise APIExceptions.InvalidUIdToken
    else:
        return JsonResponse(1, safe=False)
def validate_password_token(request):
    """Valida los tokens de contraseƱa proporcionados.

    Args:
    request: API request.
    """
    args = verify_post_params(request, ['uid', 'token'])
    user = PasswordToken.validate_token(args['uid'], args['token'])

    if user is None:
        raise APIExceptions.InvalidUIdToken
    else:
        return JsonResponse(1, safe=False)
Example #3
0
def reset_password(request):
    args = PostParametersList(request)
    args.check_parameter(key='uid', required=True)
    args.check_parameter(key='token', required=True)
    args.check_parameter(key='password', required=True)
    check = PasswordToken.reset_password(args['uid'], args['token'],
                                         args['password'])

    if check:
        user = PasswordToken.validate_token(args['uid'], args['token'])
        return JsonResponse(1 if user and user.es_admin else 2, safe=False)
    else:
        raise APIExceptions.InvalidToken.set(
            detail="Reseteo de contraseƱa invalido")