Skip to content

Commit 89efde7

Browse files
authored
Prevent instant sign-in after logout (#19)
* feat: prevent instant sign-in after logout
1 parent 439255c commit 89efde7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/app/hypermedia-view/auth.service.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ import {LogoutRedirectComponent} from "../logout-redirect/logout-redirect.compon
1818
@Injectable()
1919
export class AuthService {
2020
private tokenRecentlyAcquired: Set<string>;
21+
private recentlyLoggedOut: Set<string>;
2122

2223
private siteSpecificSettings: ImmutableMap<string, SiteSetting> = ImmutableMap();
2324
private currentEntryPoint: CurrentEntryPoint = {};
2425

2526
constructor(private settingsService: SettingsService, private store: Store<{ appSettings: AppSettings, currentEntryPoint: CurrentEntryPoint }>) {
2627
this.tokenRecentlyAcquired = new Set();
28+
this.recentlyLoggedOut = new Set();
2729

2830
this.store
2931
.select(s => s.appSettings.siteSettings.siteSpecificSettings)
@@ -65,7 +67,8 @@ export class AuthService {
6567
this.settingsService.SaveCurrentSettings();
6668

6769
try {
68-
await userManager.signinRedirect();
70+
const prompt = this.recentlyLoggedOut.has(siteUrl) ? 'select_account' : undefined;
71+
await userManager.signinRedirect({prompt: prompt});
6972
return Success(Unit.NoThing);
7073
} catch {
7174
return Failure("Error during authentication");
@@ -141,6 +144,7 @@ export class AuthService {
141144
}));
142145
}
143146
this.tokenRecentlyAcquired.add(entryPoint);
147+
this.recentlyLoggedOut.delete(siteUrl);
144148
this.store.dispatch(setAuthenticationInProgress({siteUrl: siteUrl, authenticationInProgress: false}))
145149
this.settingsService.SaveCurrentSettings();
146150
return Success(Unit.NoThing);
@@ -206,6 +210,7 @@ export class AuthService {
206210

207211
try {
208212
await userManager.signoutCallback();
213+
this.recentlyLoggedOut.add(siteUrl)
209214
this.store.dispatch(setAuthConfig({siteUrl: siteUrl, authConfig: undefined}))
210215
return Success(Unit.NoThing);
211216
} catch(err) {

0 commit comments

Comments
 (0)