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())
Example #2
0
def login():
    # Skip login form on forced SSO
    if request.method == "GET" and current_app.config["OAUTH_SKIP_LOGIN"]:
        if not request.args.get('local') and oauth_type():
            return redirect(url_for(oauth_type() + '.login'))
    form = LoginForm(request.form)
    # Handle logging in
    if request.method == 'POST':
        if form.validate_on_submit():
            login_user(form.user, remember=True)
            if not form.user.active:
                flash(
                    'This user account is under review. ' +
                    'Please update your profile and contact the organizing ' +
                    'team to access all functions of this platform.',
                    'warning')
            else:
                flash("You are logged in! Time to make something awesome ≧◡≦",
                      'success')
            redirect_url = request.args.get("next") or url_for("public.home")
            return redirect(redirect_url)
        else:
            flash_errors(form)
    return render_template("public/login.html",
                           form=form,
                           oauth_type=oauth_type())
Example #3
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)
Example #4
0
def login():
    form = LoginForm(request.form)
    # Handle logging in
    if request.method == 'POST':
        if form.validate_on_submit():
            login_user(form.user, remember=True)
            flash("You are logged in.", 'success')
            redirect_url = request.args.get("next") or url_for("public.home")
            return redirect(redirect_url)
        else:
            flash_errors(form)
    return render_template("public/login.html", current_event=get_current_event(), form=form)
def login():
    form = LoginForm(request.form)
    # Handle logging in
    if request.method == 'POST':
        if form.validate_on_submit():
            login_user(form.user, remember=True)
            flash("You are logged in.", 'success')
            redirect_url = request.args.get("next") or url_for("public.home")
            return redirect(redirect_url)
        else:
            flash_errors(form)
    return render_template("public/login.html",
                           current_event=current_event(),
                           form=form,
                           slack_enabled=slack_enabled())
Example #6
0
def login():
    # Skip login form on forced SSO
    if request.method == "GET" and current_app.config["DRIBDAT_NOT_REGISTER"]:
        if not request.args.get('local') and oauth_type():
            return redirect(url_for(oauth_type() + '.login'))
    form = LoginForm(request.form)
    # Handle logging in
    if request.method == 'POST':
        if form.validate_on_submit():
            login_user(form.user, remember=True)
            flash("You are logged in.", 'success')
            redirect_url = request.args.get("next") or url_for("public.home")
            return redirect(redirect_url)
        else:
            flash_errors(form)
    return render_template("public/login.html",
                           current_event=current_event(),
                           form=form,
                           oauth_type=oauth_type())
Example #7
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())
Example #8
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())