diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-10-09 18:42:33 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-10-09 18:42:33 +0200 |
| commit | 7bbd3891a76d3a6da20a4aa3888e6da87e41aa6d (patch) | |
| tree | c3602e6b8c3f2f79fb9c28465963365aaf49d8c4 /code/app/src/lib/session.ts | |
| parent | b2b76d0552ecf0c57a4d39fb0a1caa9b4c10bee9 (diff) | |
| download | greatoffice-7bbd3891a76d3a6da20a4aa3888e6da87e41aa6d.tar.xz greatoffice-7bbd3891a76d3a6da20a4aa3888e6da87e41aa6d.zip | |
refactor/fix: Small refactors/fixes, update imports
Diffstat (limited to 'code/app/src/lib/session.ts')
| -rw-r--r-- | code/app/src/lib/session.ts | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/code/app/src/lib/session.ts b/code/app/src/lib/session.ts index ee79933..7cd5fcf 100644 --- a/code/app/src/lib/session.ts +++ b/code/app/src/lib/session.ts @@ -1,9 +1,9 @@ -import {logError, logInfo} from "$lib/logger"; +import { log_error, log_info } from "$lib/logger"; import { Temporal } from "temporal-polyfill"; import { get_profile_for_active_check, logout } from "./api/user"; import { is_guid, session_storage_get_json, session_storage_set_json } from "./helpers"; import { SECONDS_BETWEEN_SESSION_CHECK, StorageKeys } from "./configuration"; -import type { ISession } from "$lib/models/ISession"; +import type { ISession } from "$lib/models/internal/ISession"; export async function is_active(forceRefresh: boolean = false): Promise<boolean> { const nowEpoch = Temporal.Now.instant().epochSeconds; @@ -16,7 +16,7 @@ export async function is_active(forceRefresh: boolean = false): Promise<boolean> const sessionIsValid = data.profile && is_guid(data.profile.id); if (!sessionIsValid) { clear_session_data(); - logInfo("Session data is not valid"); + log_info("Session data is not valid"); } return sessionIsValid; } @@ -29,7 +29,7 @@ export async function end_session(cb: Function): Promise<void> { } async function call_api(): Promise<boolean> { - logInfo("Getting profile data while checking session state"); + log_info("Getting profile data while checking session state"); try { const response = await get_profile_for_active_check(); if (response.ok) { @@ -40,20 +40,20 @@ async function call_api(): Promise<boolean> { lastChecked: Temporal.Now.instant().epochSeconds } as ISession; session_storage_set_json(StorageKeys.session, session); - logInfo("Successfully got profile data while checking session state"); + log_info("Successfully got profile data while checking session state"); return true; } else { - logError("Api returned invalid data while getting profile data"); + log_error("Api returned invalid data while getting profile data"); clear_session_data(); return false; } } else { - logError("Api returned unsuccessfully while getting profile data"); + log_error("Api returned unsuccessfully while getting profile data"); clear_session_data(); return false; } } catch (e) { - logError(e); + log_error(e); clear_session_data(); return false; } @@ -61,7 +61,7 @@ async function call_api(): Promise<boolean> { export function clear_session_data() { session_storage_set_json(StorageKeys.session, {}); - logInfo("Cleared session data."); + log_info("Cleared session data."); } export function get_session_data(): ISession { |
