Skip to content

Commit

Permalink
conditional auto guest login
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelmattig committed Dec 11, 2024
1 parent e60208f commit 6a94fc9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions projects/common/src/lib/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class UserService {
});
} else {
// restore old session if possible
this.sessionFromBrowserOrCreateGuest().subscribe({
this.sessionFromBrowser(this.config.USER.AUTO_GUEST_LOGIN).subscribe({
next: (session) => {
this.session$.next(session);
},
Expand Down Expand Up @@ -166,10 +166,14 @@ export class UserService {
return this.backendStatus$;
}

sessionFromBrowserOrCreateGuest(): Observable<Session> {
sessionFromBrowser(fallbackToGuest: boolean): Observable<Session | undefined> {
return this.restoreSessionFromBrowser().pipe(
catchError((_error) => {
return this.createGuestUser();
if (fallbackToGuest) {
return this.createGuestUser();
} else {
return of(undefined);
}
}),
);
}
Expand Down

0 comments on commit 6a94fc9

Please sign in to comment.