예제 #1
0
def check_login(db, usernick, password):
    cur = db.cursor()
    list = cur.execute("select * from users")

    for entry in list.fetchall():
        if usernick == entry[0]:
            if password_hash(password) == entry[1]:
                return True
            else:
                return False
    """returns True if password matches stored"""
예제 #2
0
def check_login(db, usernick, password):
    """returns True if password matches stored"""
    password = password_hash(password) 
    query = f'''SELECT * FROM users where nick='{usernick}' and password='******' '''
    cursor = db.cursor()
    cursor.execute(query)
    rows = cursor.fetchall()
    if rows:
        return True
    else:
        return False
예제 #3
0
def check_login(db, usernick, password):
    """returns True if password matches stored"""
    password = password_hash(password)
    sql = '''SELECT  * FROM users WHERE nick='%s' AND password='******';''' % (
        usernick, password)
    cursor = db.cursor()
    cursor.execute(sql)
    rows = cursor.fetchall()
    if rows:
        return True
    else:
        return False
예제 #4
0
파일: main.py 프로젝트: rako210/Comp4050
def account_update(db):

    user_id = users.return_userID(db, users.session_user(db))
    email = request.forms.get("email")
    password = request.forms.get("pword")
    suburb = request.forms.get("suburb")
    name = request.forms.get("name")
    image = request.files.get("image")
    password_flag = False
    empty_flag = False

    if (len(password) > 0):
        if (password_test(password)):
            newPassword = database.password_hash(db, password, user_id)
            if newPassword is not False:
                database.update_password(db, newPassword, user_id)
            else:
                password_flag = True
        else:
            password_flag = True
    else:
        empty_flag = True

    if (len(email) > 0) and (len(suburb) > 0) and (len(name) > 0):
        database.update_email(db, email, user_id)
        database.update_suburb(db, suburb, user_id)
        database.update_name(db, name, user_id)
    else:
        empty_flag = True

    if image is not None:
        imagePath = userImage_upload(user_id, image)
        database.update_avatar(db, user_id, imagePath)

    if empty_flag:
        return {
            'result': 'false',
            'bannerMessage': banner_messages['UpdateAccountDetailsFailEmpty']
        }

    if password_flag:
        return {
            'result': 'false',
            'bannerMessage':
            banner_messages['UpdateAccountDetailsFailPassword']
        }

    return {
        'result': "True",
        'bannerMessage': banner_messages['UpdateAccountDetailsSuccess']
    }
예제 #5
0
파일: main.py 프로젝트: rako210/Comp4050
def acc(db):
    """validates password"""
    info = {'title': 'Account', 'bannerMessage': ''}
    info1 = {'title': 'Account', 'bannerMessage': 'Wrong Password'}

    password = request.forms.get("password")
    usern = users.session_user(db)
    result = users.check_password(db, usern,
                                  database.password_hash(db, password, usern))
    if (result):
        return {'result': str(True)}
        # return template('account', info, authenticated=users.session_user(db), validated=True, invalidPword=False)
    else:
        return {'result': str(False)}
예제 #6
0
파일: main.py 프로젝트: rako210/Comp4050
def token_reset(db):
    key = itsdangerous.URLSafeSerializer(config.cred['secretKeys'])
    user = request.forms.get("user")
    out = key.loads(user)
    password = request.forms.get("pword")
    check = password_test(password)
    if check:
        userID = users.return_userID(db, out[0])
        hash = database.password_hash(db, password, userID)
        database.update_password(db, hash, userID)
        # does this redirect not work anymore???
        redirect('http://localhost:3000/')
    else:
        return template('pwordReset', user=user, pwordError=True)
def check_login(db, usernick, password):
    """returns True if password matches stored"""
    cursor = db.cursor()
    sql = '''
        SELECT nick, password
        FROM users 
        WHERE nick = (?) AND password = (?)
        '''
    cursor.execute(sql, (usernick, database.password_hash(password)))
    result = cursor.fetchone()
    if result is None:
        return False
    else:
        return True
예제 #8
0
def check_login(db, usernick, password):
    """returns True if password matches stored"""
    cursor = db.cursor()
    sql = "Select nick, password From users"
    cursor.execute(sql)
    results = cursor.fetchall()

    for i in results:
        if i[0] == usernick:
            if i[1] == password_hash(password):
                return True
            return False

    return False
예제 #9
0
def check_login(db, usernick, password):
    """returns True if password matches stored"""

    #get password hash
    pass_hash = database.password_hash(password)

    #get actual password hash stored in database
    cursor = db.cursor()
    cursor.execute("SELECT * FROM users where nick=(?) AND password=(?)",
                   (usernick, pass_hash))
    result = cursor.fetchall()

    #if both are same return true
    if (len(result) != 0):
        return True
예제 #10
0
def check_login(db, usernick, password):
    """returns True if password matches stored"""

    cur = db.cursor()

    sql = """SELECT COUNT(nick) FROM users WHERE nick=? AND password=?"""

    cur.execute(sql, (usernick, password_hash(password)))

    count = cur.fetchone()[0]

    if count > 0:
        return True

    return False
예제 #11
0
파일: users.py 프로젝트: rako210/Comp4050
def check_login(db, user, password):
    """returns True if password matches stored password for user"""
    p = password_hash(db, password,
                      user)  # convert password to a hash in order to compare
    cursor = db.cursor()

    sql = "SELECT * FROM users WHERE username=? AND password=?"
    data = cursor.execute(sql, (
        user,
        p,
    ))

    if data.fetchone():
        return True
    return False
예제 #12
0
def check_login(db, usernick, password):
    """returns True if password matches stored"""
    cursor = db.cursor()
    query = """SELECT password FROM users WHERE nick=?"""
    cursor.execute(query, [usernick])
    """Since usernick is a foreign key of nick from 'user' table, it can be used as parameter for 
    nick in the above query"""
    enpass = cursor.fetchone()
    if enpass is None:
        return False
    else:
        plaintext = enpass[0]
        hash = password_hash(password)
        if hash == plaintext:
            return True
        else:
            return False
예제 #13
0
def check_login(db, usernick, password):
    """returns True if password matches stored"""
    cursor = db.cursor()
    query = """SELECT password FROM users WHERE nick=?"""
    cursor.execute(query, [usernick])
    passcheck = cursor.fetchone()

    print(passcheck)
    print(password)
    if passcheck:
        plain = passcheck[0]
        encrypt = password_hash(password)
        if encrypt == plain:
            return True
        else:
            return False
    else:
        return False
예제 #14
0
def check_login(db, usernick, password):
    """returns True if password matches stored"""
    db_password = get_password_by_nick(usernick)
    hash_password = database.password_hash(password)
    return True if (db_password == hash_password) else False