Exemple #1
0
def get_or_create_cache_token(token, user_dict):
    user_cache = LMBCache()
    if user_cache.is_exists(token):
        cached_data = user_cache.get(token)
        if cached_data['user_id'] == user_dict['user_id'] and cached_data[
                'role'] == user_dict['role']:
            user_cache.delete(token)
    token = UserAuthentication.generate_key()
    while user_cache.is_exists(token):
        token = UserAuthentication.generate_key()
    user_dict['last_modified'] = user_cache.make_datetime_version()
    user_cache.set_token(token, user_dict)
    return token
Exemple #2
0
def get_or_create_cache_token(token, user_dict):
    user_cache = LMBCache()
    if user_cache.is_exists(token):
        cached_data = user_cache.get(token)
        if cached_data['user_id'] == user_dict['user_id'] and cached_data['role'] == user_dict['role']:
            user_cache.delete(token)
    token = UserAuthentication.generate_key()
    while user_cache.is_exists(token):
        token = UserAuthentication.generate_key()
    user_dict['last_modified'] = user_cache.make_datetime_version()
    user_cache.set_token(token, user_dict)
    return token
Exemple #3
0
def get_cache(key):
    lmb_cache = LMBCache()
    return lmb_cache.get(key)
 def is_authenticate(cls, token):
     lmb_cache = LMBCache()
     if lmb_cache.is_exists(token):
         return True
     return False
Exemple #5
0
def get_cache(key):
    lmb_cache = LMBCache()
    return lmb_cache.get(key)
 def is_authenticate(cls, token):
     lmb_cache = LMBCache()
     if lmb_cache.is_exists(token):
         return True
     return False