Beispiel #1
0
def signup():
    message = None
    global notifications
    if notifications:
        message = notifications
        notifications = None
    if request.method == 'POST':
        result = Users.signupUser(db, request.form, config['pw_rounds'])
        if not result:
            notifications = {
                'message': 'Registration successful',
                'type': 'success'
            }
            return redirect(url_for('login'))
        else:
            message = {
                'message': 'Something went wrong: ' + result,
                'type': 'error'
            }
            return render_template('sign-up.html', message=message)
    if 'uid' in session and session['uid'] == 1:
        return render_template('sign-up.html', message=message)
    if config['registration_enabled']:
        return render_template('sign-up.html', message=message)
    else:
        notifications = {
            'message': 'User registration is disabled by the admin',
            'type': 'warning'
        }
        if 'uid' in session:
            return redirect(url_for('index'))
        else:
            return redirect(url_for('login'))
Beispiel #2
0
def signup():
    message = None
    global notifications
    if notifications:
        message = notifications
        notifications = None
    if 'uid' in session:
        return redirect(url_for('index'))
    if request.method == 'POST':
        logging.info("sign up")
        result = Users.signupUser(db.conn, request.form, config['pw_rounds'])
        if not result:
            notifications = {
                'message': 'Registration successful',
                'type': 'success'
            }
            #XSS Protection
            response = make_response(redirect('gethoodlist'))
            response.headers['X-XSS-Protection'] = '1; mode=block'
            return response
        else:
            message = {
                'message': 'Something went wrong: ' + result,
                'type': 'error'
            }
            response = make_response(
                render_template('sign-up.html', message=message))
            response.headers['X-XSS-Protection'] = '1; mode=block'
            return response
    if config['registration_enabled']:
        return render_template('sign-up.html', message=message)
    else:
        notifications = {
            'message': 'User registration is disabled by the admin',
            'type': 'warning'
        }
        if 'uid' in session:
            return redirect(url_for('index'))
        else:
            return redirect(url_for('join_block'))