This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2018-12-14 12:51:12 +00:00
|
|
|
"""passbook captcha factor"""
|
|
|
|
|
|
|
|
from django.views.generic import FormView
|
|
|
|
|
2019-10-07 14:33:48 +00:00
|
|
|
from passbook.factors.captcha.forms import CaptchaForm
|
2020-05-07 19:30:52 +00:00
|
|
|
from passbook.flows.factor_base import AuthenticationFactor
|
2018-12-14 12:51:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
class CaptchaFactor(FormView, AuthenticationFactor):
|
|
|
|
"""Simple captcha checker, logic is handeled in django-captcha module"""
|
|
|
|
|
|
|
|
form_class = CaptchaForm
|
|
|
|
|
|
|
|
def form_valid(self, form):
|
2020-05-08 14:10:27 +00:00
|
|
|
return self.executor.factor_ok()
|
2019-03-08 19:08:28 +00:00
|
|
|
|
|
|
|
def get_form(self, form_class=None):
|
|
|
|
form = CaptchaForm(**self.get_form_kwargs())
|
2020-05-08 14:10:27 +00:00
|
|
|
form.fields["captcha"].public_key = self.executor.current_factor.public_key
|
|
|
|
form.fields["captcha"].private_key = self.executor.current_factor.private_key
|
2019-12-31 11:51:16 +00:00
|
|
|
form.fields["captcha"].widget.attrs["data-sitekey"] = form.fields[
|
|
|
|
"captcha"
|
|
|
|
].public_key
|
2019-03-08 19:08:28 +00:00
|
|
|
return form
|