Disabling the posibility of multiple account cancelations for the same cancel_token
parent
63364f4304
commit
be8d1719d3
|
@ -274,9 +274,13 @@ class UsersViewSet(ModelCrudViewSet):
|
||||||
max_age_cancel_account = getattr(settings, "MAX_AGE_CANCEL_ACCOUNT", None)
|
max_age_cancel_account = getattr(settings, "MAX_AGE_CANCEL_ACCOUNT", None)
|
||||||
user = get_user_for_token(serializer.data["cancel_token"], "cancel_account",
|
user = get_user_for_token(serializer.data["cancel_token"], "cancel_account",
|
||||||
max_age=max_age_cancel_account)
|
max_age=max_age_cancel_account)
|
||||||
|
|
||||||
except exc.NotAuthenticated:
|
except exc.NotAuthenticated:
|
||||||
raise exc.WrongArguments(_("Invalid, are you sure the token is correct?"))
|
raise exc.WrongArguments(_("Invalid, are you sure the token is correct?"))
|
||||||
|
|
||||||
|
if not user.is_active:
|
||||||
|
raise exc.WrongArguments(_("Invalid, are you sure the token is correct?"))
|
||||||
|
|
||||||
user.cancel()
|
user.cancel()
|
||||||
return Response(status=status.HTTP_204_NO_CONTENT)
|
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue