Skip to content

Commit

Permalink
add refreshAuth function to keel
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeistrich committed Jul 31, 2024
1 parent 897723a commit 7a7f78c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/sync-plugins/keel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export interface SyncedKeelConfiguration
action: string;
error: APIResult<any>['error'];
}) => void;
refreshAuth?: () => void | Promise<void>;
}

interface PageInfo {
Expand Down Expand Up @@ -176,6 +177,11 @@ const isEnabled$ = observable(true);

async function ensureAuthToken() {
await when(isEnabled$.get());

if (keelConfig.refreshAuth) {
await keelConfig.refreshAuth();
}

let isAuthed = await keelConfig.client.auth.isAuthenticated();
if (!isAuthed) {
isAuthed = await keelConfig.client.auth.refresh();
Expand Down

0 comments on commit 7a7f78c

Please sign in to comment.