~fluix/tilde

ref: 5eafb87dcb66444a197f18e647160b174916aad8 tilde/auth/forms.py -rw-r--r-- 1.0 KiB
5eafb87dSteven Guikal Add auth check command for ergo IRC server 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# SPDX-FileCopyrightText: 2021 Steven Guikal <void@fluix.one>
#
# SPDX-License-Identifier: AGPL-3.0-only

from wtforms import Form, PasswordField, StringField
from wtforms.validators import Email, EqualTo, InputRequired, Length, Regexp
from wtforms.widgets import TextArea


class LoginForm(Form):
    username = StringField("Username", [InputRequired()])
    password = PasswordField("Password", [InputRequired()])


class RegistrationForm(Form):
    username = StringField(
        "Username",
        [
            InputRequired(),
            Regexp("[a-zA-Z0-9]{2,20}", message="Input must be alphanumeric."),
            Length(min=2, max=20),
        ],
    )
    email = StringField("Email", [InputRequired(), Email()])
    password1 = PasswordField(
        "Password",
        [
            InputRequired(),
            Length(min=16),
            EqualTo("password2", message="Passwords must match."),
        ],
    )
    password2 = PasswordField("Password (confirm)", [InputRequired()])
    bio = StringField("Biography", [InputRequired()], widget=TextArea())