View classes

There are just two essential views in django-latch: one for letting a user configure the latch and another for unpairing it.

class django_latch.views.PairLatchView(**kwargs)[source]

Implement the pairing operation for an authenticated and unpaired user.

It is a subclass of UnpairedUserRequiredMixin, so only authenticated users without the latch configured can access it.

form_valid(form)[source]

If the form is valid, attempt to pair the user account to the Latch service and redirect to the success URL. If a django_latch:exceptions.PairingLatchError is raised, instead re-render the form and include information about the error in the template context.

Parameters:

form (django_latch.forms.PairLatchForm) – The token form to use.

class django_latch.views.UnpairLatchView(**kwargs)[source]

Implement the unpairing operation for a authenticated paired user.

It is a subclass of PairedUserRequiredMixin, so only authenticated users with the latch configured can access it.

unpair_account()[source]

Unpair the user account from the Latch service.

post(request, *args, **kwargs)[source]

Attempt to unpair the user account from the Latch service and redirect to the success URL. If a django_latch:execptions.UnpairingLatchError is raised, re-render the view and include information about the error in the template context.

check_user()[source]

Check if the logged user doesn’t have its account latched, raising UnpairingLatchError if so.