Form classes¶
The only form required by django-latch is the one used for setting up the
latch, which only asks for the generated token in the user’s mobile phone
Latch app.
- class django_latch.forms.PairLatchForm(*args, **kwargs)[source]¶
A form for pairing the user account to the Latch service.
- clean_token()[source]¶
Validate the token with the Latch service.
Because the validation of the token must be done with Latch and it returns the account id if the token is valid, we cached the account id.
If the token is not found by the Latch service, then a
django.core.exceptions.ValidationErrorwith the code'not_found'is raised. If the user has already pair its account, then adjango.core.exceptions.ValidationErroris raised with the code'already_paired'.
- pair_account(user)[source]¶
Pair the user account with a Latch account id.
As the account id has been already obtained by checking the validity of the token, this method only creates the instance for storing the account id.
Form fields:
token: Token (CharField)