def register():
    """Register new user."""
    form = RegisterForm(request.form)
    if request.args.get('name') and not form.username.data:
        form.username.data = request.args.get('name')
    if request.args.get('email') and not form.email.data:
        form.email.data = request.args.get('email')
    if request.args.get('web') and not form.webpage_url.data:
        form.webpage_url.data = request.args.get('web')
    user1 = User.query.filter_by(email=form.email.data).first()
    if user1:
        flash("A user account with this email already exists", 'warning')
    elif form.validate_on_submit():
        new_user = User.create(username=form.username.data,
                               email=form.email.data,
                               webpage_url=form.webpage_url.data,
                               password=form.password.data,
                               active=True)
        new_user.socialize()
        if User.query.count() == 1:
            new_user.is_admin = True
            new_user.save()
            flash("Administrative user created - have fun!", 'success')
        else:
            flash(
                "Thank you for registering. You can now log in and submit projects.",
                'success')
        login_user(new_user, remember=True)
        return redirect(url_for('public.home'))
    else:
        flash_errors(form)
    return render_template('public/register.html',
                           current_event=current_event(),
                           form=form,
                           slack_enabled=slack_enabled())
Esempio n. 2
0
def register():
    """Register new user."""
    form = RegisterForm(request.form)
    if request.args.get('name'):
        form.username.data = request.args.get('name')
    if request.args.get('email'):
        form.email.data = request.args.get('email')
    if request.args.get('web'):
        form.webpage_url.data = request.args.get('web')
    if form.validate_on_submit():
        new_user = User.create(
                        username=form.username.data,
                        email=form.email.data,
                        webpage_url=form.webpage_url.data,
                        password=form.password.data,
                        active=True)
        new_user.socialize()
        if User.query.count() == 1:
            new_user.is_admin = True
            new_user.save()
            flash("Administrative user created - have fun with DRIBDAT!", 'success')
        else:
            flash("Thank you for registering. You can now log in and submit projects.", 'success')
        return redirect(url_for('public.login'))
    else:
        flash_errors(form)
    return render_template('public/register.html', current_event=get_current_event(), form=form)
Esempio n. 3
0
def register():
    """Register new user."""
    if current_app.config['DRIBDAT_NOT_REGISTER']:
        flash("Registration currently not possible.", 'warning')
        return redirect(url_for("auth.login", local=1))
    form = RegisterForm(request.form)
    if request.args.get('name') and not form.username.data:
        form.username.data = request.args.get('name')
    if request.args.get('email') and not form.email.data:
        form.email.data = request.args.get('email')
    if request.args.get('web') and not form.webpage_url.data:
        form.webpage_url.data = request.args.get('web')
    if form.validate_on_submit():
        sane_username = sanitize_input(form.username.data)
        new_user = User.create(username=sane_username,
                               email=form.email.data,
                               webpage_url=form.webpage_url.data,
                               password=form.password.data,
                               active=True)
        new_user.socialize()
        if User.query.count() == 1:
            new_user.is_admin = True
            new_user.save()
            flash("Administrative user created - have fun!", 'success')
        elif current_app.config['DRIBDAT_USER_APPROVE']:
            new_user.active = False
            new_user.save()
            flash(
                "Thank you for registering. New accounts require approval " +
                "from the event organizers. Please update your profile " +
                "and await activation.", 'warning')
        else:
            flash(
                "Thank you for registering. You can now log in and submit " +
                "projects.", 'success')
        login_user(new_user, remember=True)
        return redirect(url_for('public.home'))
    else:
        flash_errors(form)
    return render_template('public/register.html',
                           form=form,
                           oauth_type=oauth_type())
Esempio n. 4
0
def register():
    """Register new user."""
    if current_app.config['DRIBDAT_NOT_REGISTER']:
        flash("Registration currently not possible.", 'warning')
        return redirect(url_for("auth.login", local=1))
    form = RegisterForm(request.form)
    if request.args.get('name') and not form.username.data:
        form.username.data = request.args.get('name')
    if request.args.get('email') and not form.email.data:
        form.email.data = request.args.get('email')
    if request.args.get('web') and not form.webpage_url.data:
        form.webpage_url.data = request.args.get('web')
    user1 = User.query.filter_by(email=form.email.data).first()
    if user1:
        flash("A user account with this email already exists", 'warning')
    elif form.validate_on_submit():
        new_user = User.create(username=sanitize_input(form.username.data),
                               email=form.email.data,
                               webpage_url=form.webpage_url.data,
                               password=form.password.data,
                               active=True)
        new_user.socialize()
        if User.query.count() == 1:
            new_user.is_admin = True
            new_user.save()
            flash("Administrative user created - have fun!", 'success')
        else:
            flash(
                "Thank you for registering. You can now log in and submit projects.",
                'success')
        login_user(new_user, remember=True)
        return redirect(url_for('public.home'))
    else:
        flash_errors(form)
    return render_template('public/register.html',
                           current_event=current_event(),
                           form=form,
                           oauth_type=oauth_type())