<s> """<STR_LIT>""" <EOL> from datetime import datetime <EOL> from flask_wtf import Form , RecaptchaField <EOL> from wtforms import ( StringField , PasswordField , BooleanField , HiddenField , <EOL> SubmitField , SelectField ) <EOL> from wtforms . validators import ( DataRequired , InputRequired , Email , EqualTo , <EOL> regexp , ValidationError ) <EOL> from flask_babelplus import lazy_gettext as _ <EOL> from flaskbb . user . models import User <EOL> USERNAME_RE = r'<STR_LIT>' <EOL> is_username = regexp ( USERNAME_RE , <EOL> message = _ ( "<STR_LIT>" ) ) <EOL> class LoginForm ( Form ) : <EOL> login = StringField ( _ ( "<STR_LIT>" ) , validators = [ <EOL> DataRequired ( message = _ ( "<STR_LIT>" ) ) ] <EOL> ) <EOL> password = PasswordField ( _ ( "<STR_LIT>" ) , validators = [ <EOL> DataRequired ( message = _ ( "<STR_LIT>" ) ) ] ) <EOL> remember_me = BooleanField ( _ ( "<STR_LIT>" ) , default = False ) <EOL> submit = SubmitField ( _ ( "<STR_LIT>" ) ) <EOL> class RegisterForm ( Form ) : <EOL> username = StringField ( _ ( "<STR_LIT>" ) , validators = [ <EOL> DataRequired ( message = _ ( "<STR_LIT>" ) ) , <EOL> is_username ] ) <EOL> email = StringField ( _ ( "<STR_LIT>" ) , validators = [ <EOL> DataRequired ( message = _ ( "<STR_LIT>" ) ) , <EOL> Email ( message = _ ( "<STR_LIT>" ) ) ] ) <EOL> password = PasswordField ( _ ( '<STR_LIT>' ) , validators = [ <EOL> InputRequired ( ) , <EOL> EqualTo ( '<STR_LIT>' , message = _ ( '<STR_LIT>' ) ) ] ) <EOL> confirm_password = PasswordField ( _ ( '<STR_LIT>' ) ) <EOL> language = SelectField ( _ ( '<STR_LIT>' ) ) <EOL> accept_tos = BooleanField ( _ ( "<STR_LIT>" ) , default = True ) <EOL> submit = SubmitField ( _ ( "<STR_LIT>" ) ) <EOL> def validate_username ( self , field ) : <EOL> user = User . query . filter_by ( username = field . data ) . first ( ) <EOL> if user : <EOL> raise ValidationError ( _ ( "<STR_LIT>" ) ) <EOL> def validate_email ( self , field ) : <EOL> email = User . query . filter_by ( email = field . data ) . first ( ) <EOL> if email : <EOL> raise ValidationError ( _ ( "<STR_LIT>" ) ) <EOL> def save ( self ) : <EOL> user = User ( username = self . username . data , <EOL> email = self . email . data , <EOL> password = self . password . data , <EOL> date_joined = datetime . utcnow ( ) , <EOL> primary_group_id = <NUM_LIT:4> , <EOL> language = self . language . data ) <EOL> return user . save ( ) <EOL> class RegisterRecaptchaForm ( RegisterForm ) : <EOL> recaptcha = RecaptchaField ( _ ( "<STR_LIT>" ) ) <EOL> class ReauthForm ( Form ) : <EOL> password = PasswordField ( _ ( '<STR_LIT>' ) , validators = [ <EOL> DataRequired ( message = _ ( "<STR_LIT>" ) ) ] ) <EOL> submit = SubmitField ( _ ( "<STR_LIT>" ) ) <EOL> class ForgotPasswordForm ( Form ) : <EOL> email = StringField ( _ ( '<STR_LIT>' ) , validators = [ <EOL> DataRequired ( message = _ ( "<STR_LIT>" ) ) , <EOL> Email ( ) ] ) <EOL> submit = SubmitField ( _ ( "<STR_LIT>" ) ) <EOL> class ResetPasswordForm ( Form ) : <EOL> token = HiddenField ( '<STR_LIT>' ) <EOL> email = StringField ( _ ( '<STR_LIT>' ) , validators = [ <EOL> DataRequired ( message = _ ( "<STR_LIT>" ) ) , <EOL> Email ( ) ] ) <EOL> password = PasswordField ( _ ( '<STR_LIT>' ) , validators = [ <EOL> InputRequired ( ) , <EOL> EqualTo ( '<STR_LIT>' , message = _ ( '<STR_LIT>' ) ) ] ) <EOL> confirm_password = PasswordField ( _ ( '<STR_LIT>' ) ) <EOL> submit = SubmitField ( _ ( "<STR_LIT>" ) ) <EOL> def validate_email ( self , field ) : <EOL> email = User . query . filter_by ( email = field . data ) . first ( ) <EOL> if not email : <EOL> raise ValidationError ( _ ( "<STR_LIT>" ) ) </s>
