Beispiel #1
0
def home():
    """
    Return the home page
    """
    if request.method == 'GET':
        user = getUser()
        if user:
            return render('home.html', {
                'user': user
            })
        else:
            return 'no user found, login'
Beispiel #2
0
def creatuser():
    """
    GET: Render the create account form
    POST: Create the user
    """
    if request.method == 'GET':
        return render('index.html')

    
    elif request.method == 'POST':
        salt =  getRandomSalt(16)
        thehash = pbkdf2_hex(request.form['password'].encode('utf-8'), salt.encode('utf-8'))

        # Make a new user out of the info
        new_user = store.add(User())
        new_user.username = request.form['username']
        new_user.salt = unicode(salt)
        new_user.hash = unicode(thehash)
        store.commit()

        # store user id in the session
        session['userid'] = new_user.id

        return redirect('/home')
Beispiel #3
0
def index():
    return render('index.html')