Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(stark-ui): add logout button on the Session Timeout Warning dialog #3479

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const translationsEn: object = {
LOGIN: "Log in again"
},
SESSION_TIMEOUT: {
CLOSE_SESSION: "Logout",
SECONDS: " seconds.",
STAY_CONNECTED: "Stay connected",
TITLE: "Session about to expire",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const translationsFr: object = {
LOGIN: "Connexion"
},
SESSION_TIMEOUT: {
CLOSE_SESSION: "Se déconnecter",
SECONDS: " secondes.",
STAY_CONNECTED: "Rester connecté",
TITLE: "Session sur le point d'expirer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const translationsNl: object = {
LOGIN: "Opnieuw aanmelden"
},
SESSION_TIMEOUT: {
CLOSE_SESSION: "Afmelden",
SECONDS: " seconden vervallen.",
STAY_CONNECTED: "Blijf verbonden",
TITLE: "Sessie verlopen",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ <h1 mat-dialog-title translate>STARK.SESSION_TIMEOUT.TITLE</h1>
<button mat-raised-button color="primary" (click)="keepSession()" aria-label="Close Dialog">
<span translate>STARK.SESSION_TIMEOUT.STAY_CONNECTED</span>
</button>
<button mat-raised-button (click)="closeSession()" aria-label="Close Dialog">
<span translate>STARK.SESSION_TIMEOUT.CLOSE_SESSION</span>
</button>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,14 @@ describe("SessionTimeoutWarningDialogComponent", () => {
expect(mockDialogRef.close).toHaveBeenCalledWith("keep-logged");
}));
});

describe("closeSession", () => {
it("should close the windows when the button is clicked", fakeAsync(() => {
component.ngOnInit();
component.closeSession();

expect(mockDialogRef.close).toHaveBeenCalledTimes(1);
expect(mockDialogRef.close).toHaveBeenCalledWith("close-session");
}));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,8 @@ export class StarkSessionTimeoutWarningDialogComponent implements OnInit {
public keepSession(): void {
this.dialogRef.close("keep-logged");
}

public closeSession(): void {
this.dialogRef.close("close-session");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ export class StarkSessionTimeoutWarningDialogEffects implements OnRunEffects {
})
.afterClosed()
.subscribe((result: string) => {
if (result && result === "keep-logged") {
this.sessionService.resumeUserActivityTracking();
if (result) {
if (result === "keep-logged") {
this.sessionService.resumeUserActivityTracking();
} else if (result === "close-session") {
this.sessionService.logout();
}
}
});
})
Expand Down
2 changes: 1 addition & 1 deletion showcase/src/stark-app-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"logoutUrl": "http://localhost:5001/logout",
"baseUrl": "/",
"sessionTimeout": 1337,
"sessionTimeoutWarningPeriod": 20,
"sessionTimeoutWarningPeriod": 20,
"keepAliveUrl": "http://localhost:5000/keepalive",
"keepAliveInterval": 20,
"angularDebugInfoEnabled": null,
Expand Down