예제 #1
0
def login():
    if 'user' in session:
        return redirect(url_for("homepage"))
    
        
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        user = User(username)
        user.database = db
        try:
            user.load(username)
        except:
            flash(u"Invalid Username or Password", "error")
            return render_template('auth/login.html')
            
        if user.verify_login(username, password):
            flash(u"Welcome back %s %s" % (user.first_name, user.second_name), "info" )
            session['user'] = username
        else:
            flash(u"Invalid Username or Password", "error")
            return render_template('auth/login.html')
        return render_template('auth/login.html')

    return render_template('auth/login.html')
예제 #2
0
def show_profile(username):
    """Show user Profile"""
    user = get_user(session['user'], db)
    profile = User(username)
    profile.database = db
    if not profile.already_exist():
        flash("Username not exists")
        redirect(url_for("homepage"))

    profile.load(username)
    return render_template("profile.html", user=user, profile=profile)