Esempio n. 1
0
def check_token(token):
    try:
        user_check = query_auth.select_db(od_users,
                                          od_users.public_key,
                                          value=token)
        password = user_check[0][5]
        if password != hashing_password(token) or user_check[0][6] == 0:
            return abort(401)
        set_redis(token, user_check[0][1], 86400)
        return True
    except Exception as e:
        return abort(401)
Esempio n. 2
0
def get_user_id(token):
    try:
        user_check = query.select_db(od_users,
                                     od_users.public_key,
                                     value=token)
        password = a[0][5]
        if password == hashing_password(token):
            return True
    except Exception as e:
        return abort(401)
Esempio n. 3
0
 def token_decorator(*args, **kwargs):
     token = request.headers.get('token')
     if check_token(token) != True:
         abort(401)
     return f(*args, **kwargs)
Esempio n. 4
0
 def decorated(*args, **kwargs):
     auth = request.authorization
     if not auth or not check_auth(auth.username, auth.password):
         return abort(401)
     return f(*args, **kwargs)