Esempio n. 1
0
def auth_register():
    '''
    Validate registration information.
    '''
    username = request.form.get('username', False)
    email = request.form.get('email', False)
    password = request.form.get('password', False)
    next = request.form.get('next', False)
    
    userCased = helpers.registerUser(username, email, password)
    if userCased > 3:
        # no errors - create session and redirect to next URL
        next = helpers.makeRelativeUrl(next)
        helpers.makeSession(g.session, userCased)
        return redirect(next)

    # invalid, so show errors
    return redirect(url_for('register', u=username, e=email, n=next, r=userCased))
Esempio n. 2
0
def auth_login():
    '''
    Validate username and password and go to next url.
    If invalid, go back to login form with error(s).
    '''
    username = request.form.get('username', False)
    password = request.form.get('password', False)
    next = request.form.get('next', False)

    # validate entered email and password
    userCased = helpers.loginUser(username, password)
    if userCased:
        # create session and redirect to next URL
        next = helpers.makeRelativeUrl(next)
        helpers.makeSession(g.session, userCased)
        return redirect(next)

    # invalid, so show errors
    return redirect(url_for('login', u=username, n=next, r=1))