Example #1
0
def verify_password(username_or_token, password=None):
    global database
    #database = lib.get_db()
    LOGGER = lib.get_logger(PROCESS)
    print("Will Verify User: {}, {}", username_or_token, password)
    # First try to verify via token
    user_rec = Users.verify_auth_token(app.config['SECRET_KEY'],
                                       username_or_token)
    if user_rec is None:
        # try to authenticate with username/password
        user_rec = Users.get(username_or_token, password)
    if user_rec is None:
        return False
    g.user = user_rec
    return True
Example #2
0
def verify_password(username_or_token, password=None):
    global database
    #database = lib.get_db()
    LOGGER = lib.get_logger(PROCESS)
    debug and LOGGER.warn("Will Verify User: {}, {}".format(username_or_token, password))
    # First try to verify via token
    user_rec = Users.verify_auth_token(app.config['SECRET_KEY'], username_or_token)
    if user_rec is None:
        # try to authenticate with username/password
        user_rec = Users.get(username_or_token, password)
    if user_rec is None:
        return False
    g.user = user_rec
    # Cache username<->user_id in redis for our stratum server
    redis_key = redis_userid_key + user_rec.username
    r.set(redis_key, user_rec.id)
    return True