示例#1
0
def signup():
    form = SignupForm()
    if form.validate_on_submit():
        user = User(username=form.username.data,
                    email=form.email.data,
                    password=form.password.data)
        db.session.add(user)
        db.session.commit()
        flash(f'Welcome {user.username}!, Please login to continue')
        return redirect(url_for('login'))
    return render_template('signup.html', form=form)
示例#2
0
文件: views.py 项目: yavrib/thermos
def signup():
    form = SignupForm()
    if form.validate_on_submit():
        user = User(email=form.email.data,
                    username=form.username.data,
                    password=form.password.data)
        db.session.add(user)
        db.session.commit()
        flash('Welcome, {}! Please login.'.format(user.username))
        return redirect(url_for('login'))
    return render_template("signup.html", form=form)
def signup():
    form = SignupForm()
    if form.validate_on_submit():
        usr = User(email=form.email.data,
                   username=form.username.data,
                   password=form.password.data)
        db.session.add(usr)
        db.session.commit()
        flash('Welcome, {}! Please login.'.format(usr.username))
        return redirect(url_for('login'))
    return render_template("signup.html", form=form)
示例#4
0
def signup():
    form = SignupForm()
    if form.validate_on_submit():
        user = User(email=form.email.data,
                    username=form.username.data,
                    password=form.password.data)
        db.session.add(user)
        db.session.commit()
        flash("Welcome {} to Thermos App. Please login now to your account.".
              format(user.username))
        return redirect(url_for("login"))
    return render_template("signup.html", form=form)
示例#5
0
def signup():
    form = SignupForm()
    if form.validate_on_submit():
        user = User(email=form.email.data,
                    username=form.username.data,
                    password=form.password.data)
        invalidUsername = User.getByUsername(form.username.data)
        invalidEmail = User.getByEmail(form.email.data)
        if invalidUsername is None and invalidEmail is None:
            db.session.add(user)
            db.session.commit()
            flash('Welcome, {}! Please login.'.format(user.username))
            return redirect(url_for('login'))
        elif invalidUsername:
            flash('Username has already been registered by another user.')
        elif invalidEmail:
            flash(
                'E-mail address has already been registered by another user.')
    return render_template("signup.html", form=form)