def get_user_id_via_auth_cookie(request: Request) -> Optional[int]: if auth_cookie_name not in request.cookies: return None val = request.cookies[auth_cookie_name] parts = val.split(':') if len(parts) != 2: return None user_id = parts[0] hash_val = parts[1] hash_val_check = __hash_text(user_id) if hash_val != hash_val_check: print("Warning: Hash mismatch, invalid cookie value") return None return try_int(user_id)
def get_user_id_via_auth_cookie(request: Request) -> Optional[int]: if AUTH_COOKIE_NAME not in request.cookies: return None val = request.cookies[AUTH_COOKIE_NAME] parts = val.split(':') if len(parts) != 2: return None user_id = parts[0] hash_val = parts[1] hash_val_check = __hash_text(user_id) if hash_val != hash_val_check: print('Warning: Hash Mismatch, invalid cookie value!') return None return try_int(user_id)
def make_version_num(version_text): major, minor, build = 0, 0, 0 if version_text: version_text = version_text.split('b')[0] parts = version_text.split('.') if len(parts) == 1: major = try_int(parts[0]) elif len(parts) == 2: major = try_int(parts[0]) minor = try_int(parts[1]) elif len(parts) == 3: major = try_int(parts[0]) minor = try_int(parts[1]) build = try_int(parts[2]) return major, minor, build