Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# -*- coding: utf-8 -*-
from flask_babelex import lazy_gettext as _
from flask_wtf import FlaskForm
from sqlalchemy.sql import and_, exists
from wtforms import fields, validators, widgets
from apollo import constants, models, services
class UserDetailsForm(FlaskForm):
username = fields.StringField(_('Username'))
email = fields.StringField(_('Email'), validators=[
validators.DataRequired(), validators.Email()])
password = fields.StringField(
_('Password'),
validators=[validators.EqualTo('password_confirm')],
widget=widgets.PasswordInput())
password_confirm = fields.StringField(
_('Confirm Password'),
widget=widgets.PasswordInput())
locale = fields.SelectField(_('Language'),
choices=constants.LANGUAGE_CHOICES)
def __init__(self, *args, **kwargs):
self.instance = kwargs.get('instance')
if self.instance:
initial_data = {
'email': self.instance.email,
'locale': self.instance.locale,
'username': self.instance.username,
}
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from flask.ext.wtf import Form
from wtforms import StringField, BooleanField, SelectField, TextAreaField, SubmitField, \
PasswordField, ValidationError, RadioField
from flask_wtf.file import FileField, FileAllowed, FileRequired
from wtforms.validators import DataRequired, Email, EqualTo
from app import db
class SignupForm(Form):
firstname = StringField('First name', validators=[DataRequired("Please enter your first name.")])
lastname = StringField('Last name', validators=[DataRequired("Please enter your last name.")])
email = StringField('Email', validators=[DataRequired("Please enter your email address."),
Email("Please enter your email address.")])
password = PasswordField('Password', validators=[DataRequired("Please enter a password."),
EqualTo('confirm', message="Passwords must match")])
confirm = PasswordField('Repeat Password')
class LoginForm(Form):
email = StringField('Email', validators=[DataRequired("Please enter your email address."),
Email("Please enter your email address.")])
password = PasswordField('Password', validators=[DataRequired("Please enter a password.")])
remember_me = BooleanField('remember_me', default=False)
class UploadForm(Form):
do_action = StringField('Action')
ros_file = FileField('Upload ROS File Name', validators=[FileRequired('The ROS package filename is required'), FileAllowed(['zip'], 'Zipped ROS installable file only!')])
manifest_file = FileField('Upload Manifiest File Name', validators=[FileRequired('The mainifest filename is required'), FileAllowed(['json'], 'Json manifest file only!')])
comments = StringField('Optional Comments')
class NodeForm(Form):
nodename = StringField('Nodename', validators=[DataRequired("Please enter the Nodename.")])
class RegistrationForm(FlaskForm):
first_name = StringField(
'First name', validators=[InputRequired(),
Length(1, 64)])
last_name = StringField(
'Last name', validators=[InputRequired(),
Length(1, 64)])
email = EmailField(
'Email', validators=[InputRequired(),
Length(1, 64),
Email()])
password = PasswordField(
'Password',
validators=[
InputRequired(),
EqualTo('password2', 'Passwords must match')
])
password2 = PasswordField('Confirm password', validators=[InputRequired()])
submit = SubmitField('Register')
def validate_email(self, field):
if User.query.filter_by(email=field.data).first():
raise ValidationError(
'Email already registered. (Did you mean to log in instead?)')
class RequestResetPasswordForm(FlaskForm):
email = EmailField(
'Email', validators=[InputRequired(),
Length(1, 64),
Email()])
submit = SubmitField('Reset password')
#
# You should have received a copy of the GNU General Public License
# along with Partify. If not, see .
"""Contains forms needed for user interactions, such as registering a new user or logging in."""
from wtforms import Form
from wtforms import PasswordField
from wtforms import TextField
from wtforms import validators
class SettingsForm(Form):
"""A form for soliciting a change in settings for the user."""
name = TextField("Display Name", [validators.Required(), validators.Length(min=1, max=32)])
current_password = PasswordField("Current Password")
new_password = PasswordField("New Password", [validators.EqualTo('confirm_password', message="Passwords must match!")])
confirm_password = PasswordField("Confirm Password")
class RegistrationForm(Form):
"""A form for handling registration information."""
name = TextField("Your Name", [validators.Required(), validators.Length(min=1, max=32)])
username = TextField('Username', [validators.Length(min=1, max=32), validators.Required()])
password = PasswordField('Password', [validators.Required(), validators.Length(min=1)])
class LoginForm(Form):
"""A form for taking login data."""
username = TextField('Username', [validators.Length(min=1, max=32), validators.Required()])
password = PasswordField('Password', [validators.Required(), validators.Length(min=1)])
class EmailLoginForm(SeaSurfForm):
email = wtforms.StringField(validators=[wtforms.validators.DataRequired(), wtforms.validators.Email()])
password = wtforms.PasswordField(_('Password'), [wtforms.validators.DataRequired()])
class PasswordRecoveryForm(SeaSurfForm):
email = wtforms.StringField(validators=[wtforms.validators.DataRequired(), wtforms.validators.Email()])
class PasswordResetForm(SeaSurfForm):
password = wtforms.PasswordField(_('Password'), [
wtforms.validators.DataRequired()
])
confirm = wtforms.PasswordField(_('Repeat Password'), [
wtforms.validators.EqualTo('password', message=_('Passwords must match'))
])
class AddEmailForm(SeaSurfForm):
action = wtforms.HiddenField(default='add-email')
email = wtforms.StringField(validators=[wtforms.validators.DataRequired(), wtforms.validators.Email()])
first_name = StringField('First name', validators=[
DataRequired(),
Length(1, 64)
])
last_name = StringField('Last name', validators=[
DataRequired(),
Length(1, 64)
])
email = EmailField('Email', validators=[
DataRequired(),
Length(1, 64),
Email()
])
password = PasswordField('Password', validators=[
DataRequired(),
EqualTo('password2', 'Passwords must match')
])
password2 = PasswordField('Confirm password', validators=[DataRequired()])
submit = SubmitField('Register')
def validate_email(self, field):
if User.query.filter_by(email=field.data).first():
raise ValidationError('Email already registered. (Did you mean to '
'<a href="{}">log in</a> instead?)'
.format(url_for('account.login')))
class RequestResetPasswordForm(Form):
email = EmailField('Email', validators=[
DataRequired(),
Length(1, 64),
Email()])
from wtforms_html5 import AutoAttrMeta
from caas.provider.models import App, Cluster, User
class RegisterForm(Form):
"""Register form."""
username = wtforms.StringField('Username',
validators=[validators.DataRequired(), validators.Length(min=3, max=25)])
email = wtforms.StringField('Email',
validators=[validators.DataRequired(), validators.Email(), validators.Length(min=6, max=40)])
password = wtforms.PasswordField('Password',
validators=[validators.DataRequired(), validators.Length(min=6, max=40)])
confirm = wtforms.PasswordField('Verify password',
[validators.DataRequired(), validators.EqualTo('password', message='Passwords must match')])
def __init__(self, *args, **kwargs):
"""Create instance."""
super(RegisterForm, self).__init__(*args, **kwargs)
self.user = None
def validate(self):
"""Validate the form."""
initial_validation = super(RegisterForm, self).validate()
if not initial_validation:
return False
user = User.query.filter_by(username=self.username.data).first()
if user:
self.username.errors.append('Username already registered')
return False
user = User.query.filter_by(email=self.email.data).first()
from .models import User, Company, db, Job, FINANCE_STAGE, FIELD, EDUCATION, EXP
from .app import uploaded_resume, uploaded_logo
import time
import random
import hmac
class RegisterUserForm(FlaskForm):
email = StringField('邮箱', validators=[DataRequired(message='请填写内容'),
Email(message='请输入合法的email地址')])
password = PasswordField('密码', validators=[DataRequired(message='请填写密码'),
Length(6, 24, message='须在6~24个字符之间'),
Regexp(r'^[a-zA-Z]+\w+', message='仅限使用英文、数字、下划线,并以英文开头')])
repeat_password = PasswordField('重复密码', validators=[DataRequired(message='请填写密码'),
EqualTo('password', message='两次密码不一致')])
name = StringField('姓名', validators=[DataRequired(message='请填写内容'),
Length(2, 8, message='须在2~8个字符之间')])
submit = SubmitField('提交')
def validate_email(self, field):
if User.query.filter_by(email=field.data).first() or \
Company.query.filter_by(email=field.data).first():
raise ValidationError('邮箱已被其他账号使用')
def create_user(self):
user = User()
user.name = self.name.data
user.email = self.email.data
user.password = self.password.data
user.id = int(time.time() * 100000000)
db.session.add(user)
def existscheck(form, field):
test = models.Account.pull(form.w.data)
if test:
raise ValidationError('Taken! Please try another.')
class RegisterForm(Form):
w = StringField('Username', [ReservedUsernames(), validators.Length(min=3, max=25), existscheck])
n = StringField('Email Address', [
validators.Length(min=3, max=254),
validators.Email(message='Must be a valid email address')
])
s = PasswordField('Password', [
validators.DataRequired(),
validators.EqualTo('c', message='Passwords must match')
])
c = PasswordField('Repeat Password')
roles = StringField('Roles')
@blueprint.route('/register', methods=['GET', 'POST'])
@login_required
@ssl_required
@write_required()
def register():
if not app.config.get('PUBLIC_REGISTER', False) and not current_user.has_role("create_user"):
abort(401)
form = RegisterForm(request.form, csrf_enabled=False, roles='api')
if request.method == 'POST' and form.validate():
account = models.Account.make_account(
username=form.w.data,
def password_wrong(form, field):
user = User.query.filter_by(username=form.username.data).first()
if user == None:
raise ValidationError("Incorrect password and username combination")
if not user.check_password(form.password.data):
raise ValidationError("Incorrect password and username combination")
class LoginForm(Form):
username = TextField("Username", [validators.DataRequired(), username_dne, username_one_word])
password = PasswordField("Password", [validators.DataRequired(), password_wrong])
remember_me = BooleanField("Remember Me")
submit = SubmitField("Sign in")
class RegisterForm(Form):
username = TextField("Username", [validators.Length(5,25), username_exist, username_one_word])
password = PasswordField("Password",[validators.length(7, 25), validators.EqualTo('retype_password', message = "Passwords must match")])
retype_password = PasswordField("Retype Password", [validators.DataRequired()])
submit = SubmitField("Create Account")