Skip to content

Differentiate bad signature from already used signatures #103

@ppawlak

Description

@ppawlak

Checklist

Is your feature request related to a problem? Please describe.

From what I read in the source code there are no specific exception when a signature had already been used. It just raise a BadSignature:
https://github.com/apragacz/django-rest-registration/blob/master/rest_registration/utils/verification.py#L9
This is because the salt used is not the same after the account had been registered and from the comments this seems by design:
https://github.com/apragacz/django-rest-registration/blob/master/rest_registration/api/views/register.py#L46

The problem is it can lead to a bad user experience. For example, in our setup we have REGISTER_VERIFICATION_AUTO_LOGIN and REGISTER_VERIFICATION_ONE_TIME_USE enabled. If a user follows the verification link on a device, he got registered and logged in. Later on he follows the link on an other device and here we are only able to show a generic error message: "The link is invalid."

Describe the solution you'd like

  • We would like a specific exception to be raised like SignatureAlreadyUsed
    OR
  • if there was a way to override the verify_registration endpoint we could first check if a user is verified and if not go on with the usual verification

In both cases this will allow us to display a relevant error message to our users like "You are already verified, please log in"

Describe alternatives you've considered

We tried to enable REGISTER_VERIFICATION_AUTO_LOGIN and disable REGISTER_VERIFICATION_ONE_TIME_USE but this leads to this error:

REGISTER_VERIFICATION_AUTO_LOGIN is enabled, but REGISTER_VERIFICATION_ONE_TIME_USE is not enabled. This can allow multiple logins using the verification url.

This is indeed not ideal for security.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions