Skip to content

Commit 98812ad

Browse files
committed
Cache skip for loginInit with invitation
1 parent 8031cd5 commit 98812ad

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

packages/web-core/src/services/ConnectService.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,13 @@ export class ConnectService {
124124

125125
async loginInit(abortController: AbortController): Promise<Result<ConnectLoginInitData, CorbadoError>> {
126126
const existingProcess = ConnectProcess.loadFromStorage(this.#projectId);
127-
if (existingProcess) {
127+
if (
128+
existingProcess?.loginData &&
129+
!existingProcess?.loginData.loginAllowed &&
130+
ConnectInvitation.loadFromStorage()?.token
131+
) {
132+
existingProcess.resetLoginData().persistToStorage();
133+
} else if (existingProcess) {
128134
log.debug('process exists, preparing api clients');
129135
this.#setApisV2(existingProcess);
130136

@@ -144,14 +150,11 @@ export class ConnectService {
144150
}
145151

146152
const existingProcessFromOtherLoginInit = ConnectProcess.loadFromStorage(this.#projectId);
147-
if (existingProcessFromOtherLoginInit) {
153+
if (existingProcessFromOtherLoginInit?.loginData) {
148154
log.debug('process exists (after login init attempt');
149155
this.#setApisV2(existingProcessFromOtherLoginInit);
150156

151-
// process has already been initialized
152-
if (existingProcessFromOtherLoginInit?.loginData) {
153-
return Ok(existingProcessFromOtherLoginInit.loginData);
154-
}
157+
return Ok(existingProcessFromOtherLoginInit.loginData);
155158
}
156159

157160
// if the backend decides that a new client handle is needed, we store it in local storage

0 commit comments

Comments
 (0)