示例#1
0
def signup():

    form = SignupForm()
    
    if request.method == 'POST':
        if form.validate() == False:
            return render_template("authentication/signup.html", form=form)
        else:
            new_user = User(form.username.data, form.email.data, form.password.data)
            db.session.add(new_user)
            db.session.commit()

            session['email'] = new_user.email
            return "Not found"
        
    elif request.method == 'GET':
        return render_template("authentication/signup.html", form=form)
示例#2
0
def signup():

    form = SignupForm()

    if "email" is session:
        return redirect(url_for("profile"))

    if request.method == "POST":
        if form.validate() == False:
            return render_template("authentication/signup.html", form=form)
        else:
            new_user = User(form.username.data, form.email.data, form.password.data)
            db.session.add(new_user)
            db.session.commit()

            session["email"] = new_user.email
            return "Not found"

    elif request.method == "GET":
        return render_template("authentication/signup.html", form=form)
示例#3
0
def signup():
    form = SignupForm()
    if ('token' in session) and (User.verify_token(session['token'])):
        return redirect(url_for('auth.profile'))
    if request.method == 'POST':
        if form.validate() is False:
            return render_template("authentication/signup.html", form=form)
        else:
            new_user = User(form.username.data,
                            form.email.data,
                            form.password.data,
                            READ_ROLE + COMMENT_ROLE + WRITE_ROLE, 1)
            db.session.add(new_user)
            db.session.commit()
            session['user_id'] = new_user.id
            session['token'] = new_user.generate_token()
            session['email'] = new_user.email
            session['user_name'] = new_user.username
        return redirect(url_for('auth.profile'))
    elif request.method == 'GET':
        return render_template("authentication/signup.html", form=form)
示例#4
0
def signup():

    form = SignupForm()

    if 'email' is session:
        return redirect(url_for('profile'))

    if request.method == 'POST':
        if form.validate() == False:
            return render_template("authentication/signup.html", form=form)
        else:
            new_user = User(form.username.data, form.email.data,
                            form.password.data)
            db.session.add(new_user)
            db.session.commit()

            session['email'] = new_user.email
            return "Not found"

    elif request.method == 'GET':
        return render_template("authentication/signup.html", form=form)