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")
def reset_password(request): """Verificar que el reseteo de la contraseña sea válido. Si es así entonces manda un check, si no manda una excepción. Args: request: API request. """ args = verify_post_params(request, ['uid', 'token', 'password']) check = PasswordToken.reset_password(args['uid'], args['token'], args['password']) if check: check.is_active = True check.save() return JsonResponse(1 if check and check.es_admin else 2, safe=False) else: raise APIExceptions.InvalidToken.set( detail="Reseteo de contraseña inválido")