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.
authentik/passbook/core/forms/authentication.py
2018-11-11 13:41:48 +01:00

21 lines
667 B
Python

"""passbook core authentication forms"""
from django import forms
from django.core.validators import validate_email
from passbook.lib.config import CONFIG
class LoginForm(forms.Form):
"""Allow users to login"""
uid_field = forms.CharField()
password = forms.CharField(widget=forms.PasswordInput())
remember_me = forms.BooleanField(required=False)
def clean_uid_field(self):
"""Validate uid_field after EmailValidator if 'email' is the only selected uid_fields"""
if CONFIG.y('passbook.uid_fields') == ['email']:
validate_email(self.cleaned_data.get('uid_field'))
return self.cleaned_data.get('uid_field')