Exemplo n.º 1
0
def login():
    pop_game_explorer_query()
    error = None
    if request.method == 'POST':
        if DEBUG:
            print("LOGGING IN with username=%(username)s, "
                                  "password=%(password)s" % request.form)  
        cursor = g.db.cursor()
        database.execSqlWithParams(cursor, database.sqlSelectUser, request.form)
        userInfo = cursor.fetchone()
        cursor.close()
        if  userInfo == None:
            error = 'Invalid username or password'
        else:
            uuid, username, password, email = userInfo
            user = User()
            user.id = uuid
            user.username = username
            user.password = password
            user.email = email
            login_user(user)
            flash('Congratulations! You have successfully logged in.')
            if 'redirectToCollectionExplorer' in session:
                session.pop('redirectToCollectionExplorer')
                return redirect(url_for('collection_explorer'))
            else: 
                return redirect(url_for('game_explorer'))
    return render_template('login.html', error=error)
Exemplo n.º 2
0
def login():
    pop_game_explorer_query()
    error = None
    if request.method == 'POST':
        if DEBUG:
            print("LOGGING IN with username=%(username)s, "
                  "password=%(password)s" % request.form)
        cursor = g.db.cursor()
        database.execSqlWithParams(cursor, database.sqlSelectUser,
                                   request.form)
        userInfo = cursor.fetchone()
        cursor.close()
        if userInfo == None:
            error = 'Invalid username or password'
        else:
            uuid, username, password, email = userInfo
            user = User()
            user.id = uuid
            user.username = username
            user.password = password
            user.email = email
            login_user(user)
            flash('Congratulations! You have successfully logged in.')
            if 'redirectToCollectionExplorer' in session:
                session.pop('redirectToCollectionExplorer')
                return redirect(url_for('collection_explorer'))
            else:
                return redirect(url_for('game_explorer'))
    return render_template('login.html', error=error)
Exemplo n.º 3
0
def load_user(uuid):
    cursor = g.db.cursor()
    user_query = ("SELECT u.uuid, u.username, u.password, u.email "
                  "FROM Users u "
                  "WHERE u.uuid = %(uuid)s")
    params = dict(uuid=uuid)
    database.execSqlWithParams(cursor, user_query, params)
    row = cursor.fetchone()
    cursor.close()
    if not row: return None
    user = User()
    user.id = row[0]
    user.username = row[1]
    user.password = row[2]
    user.email = row[3]
    return user
Exemplo n.º 4
0
def load_user(uuid):
    cursor = g.db.cursor()
    user_query = (
        "SELECT u.uuid, u.username, u.password, u.email "
        "FROM Users u "
        "WHERE u.uuid = %(uuid)s"
        )
    params = dict(uuid=uuid)
    database.execSqlWithParams(cursor,user_query,params)
    row = cursor.fetchone()
    cursor.close()
    if not row: return None
    user = User()
    user.id = row[0]
    user.username = row[1]
    user.password = row[2]
    user.email = row[3]
    return user