예제 #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)
예제 #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)
예제 #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
예제 #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