Exemple #1
0
def signup():
    if g.user is not None and g.user.is_authenticated():
        return redirect(url_for('index'))

    form = SignupForm()
    if form.validate_on_submit():
        new_user = User(form.username.data, form.email.data, form.password.data)
        mail_activation = UserMailActivation(new_user)

        db.session.add(new_user)
        db.session.add(mail_activation)
        db.session.commit()

        result, message = send_email(
            'Framgia Level Checker - Account Confirmation',
            app.config['MAIL_SENDERS']['admin'],
            [new_user.email],
            'confirm_activation',
            dict(token=mail_activation.token)
        )
        if not result:
            form.email.errors.append('Error: ' + message)
        else:
            return render_template('user/confirm_mail_sent.html', user=new_user)

    return render_template('user/signup.html', form=form)
Exemple #2
0
def signup():
    form = SignupForm()
    if form.validate_on_submit():
        new_user = User(form.email.data, form.student_id.data, 'changeme')
        new_user.update_login_info(request.environ['REMOTE_ADDR'])
        db.session.add(new_user)
        db.session.commit()

        login_user(new_user)
        return redirect(request.args.get('next') or url_for('index'))

    return render_template('user/signup.html', form=form)
Exemple #3
0
def signup():
    form = SignupForm()
    if form.validate_on_submit():
        new_user = User(form.email.data, form.student_id.data, 'changeme')
        new_user.update_login_info(request.environ['REMOTE_ADDR'])
        db.session.add(new_user)
        db.session.commit()

        login_user(new_user)
        return redirect(request.args.get('next') or url_for('index'))

    return render_template('user/signup.html', form=form)
Exemple #4
0
def signup():
    form = SignupForm()
    print(form.validate_on_submit())
    if form.validate_on_submit():
        print(form.email.data)
        name = form.name.data
        email = form.email.data
        password = form.password.data
        password1 = form.password_conf.data
        if password != password1:
            return '<h1>Password do not match!</h1>'
        hashed_pwd = bcrypt.hashpw(password.encode('utf8'), bcrypt.gensalt())
        if bcrypt.checkpw(password.encode('utf8'), hashed_pwd):
            res = add_user(email, hashed_pwd, name)
        if res:
            session['email'] = email
            session['name'] = name
            return redirect(url_for('index'))
        else:
            return redirect(url_for('user.login'))

    return render_template('signup.html', form=form)
Exemple #5
0
def signup():
    if current_user.is_authenticated:
        return 'you need to logout to access this page'
    form = SignupForm()
    if form.validate_on_submit():
        user = User(name=form.name.data,
                    username=form.username.data,
                    email=form.email.data)
        user.set_password(form.password.data)
        db.session.add(user)
        user.self_follow
        db.session.commit()
        return redirect(url_for('user.confirm'))
    return render_template('signup.html', form=form)
Exemple #6
0
def signup():
    if current_user.is_authenticated:
        return 'you need to logout to access this page'
    form = SignupForm()
    if form.validate_on_submit():
        user = User(name=form.name.data,
                    username=form.username.data,
                    email=form.email.data)
        user.set_password(form.password.data)
        db.session.add(user)
        user.self_follow
        db.session.commit()
        login_user(user, remember=True)
        flash(
            f'Account has been created for { user.username } please confirm your e-mail',
            'success')
        return redirect(url_for('user.confirm'))
    return render_template('signup.html', form=form)