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

feat(stark-core): allow customizing Login and Preloading states via the StarkSessionConfig #766

Merged
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
160 changes: 80 additions & 80 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
import {InjectionToken} from "@angular/core";
import { InjectionToken } from "@angular/core";

/**
* The InjectionToken version of the config name
*/
export const STARK_SESSION_CONFIG: InjectionToken<StarkSessionConfig> = new InjectionToken<
StarkSessionConfig
>("StarkSessionConfig");
export const STARK_SESSION_CONFIG: InjectionToken<StarkSessionConfig> = new InjectionToken<StarkSessionConfig>("StarkSessionConfig");

/**
* Definition of the configuration object for the Stark Session service
*/
export interface StarkSessionConfig {
/**
* Router state for the Login page where the user can choose a profile and use it to impersonate himself as someone else.
* This state is only used in DEVELOPMENT.
*/
loginStateName?: string;

/**
* Router state for the Preloading page where the user profile is fetched and used to automatically log the user in.
* This state is only used in PRODUCTION.
*/
preloadingStateName?: string;

/**
* Router state for the Session Expired page to be shown when the user has been automatically logged out.
* Such automatic logout occurs when the timeout of the session expiration timer (triggered due to user inactivity) is reached.
* This state is used in PRODUCTION and DEVELOPMENT.
*/
sessionExpiredStateName?: string;

/**
* Router state for the Session Logout Page that will be shown when the user intentionally logs out from the application.
* This state is used in PRODUCTION and DEVELOPMENT.
*/
sessionLogoutStateName?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe("Service: StarkSessionService", () => {
roles: ["a role", "another role", "yet another role"]
};
const mockSessionConfig: StarkSessionConfig = {
sessionExpiredStateName: "mock-session-state-name"
sessionExpiredStateName: "mock-session-expired-state-name"
};

// Inject module dependencies
Expand Down Expand Up @@ -503,7 +503,8 @@ describe("Service: StarkSessionService", () => {
appConfig,
mockIdleService,
mockInjectorService,
mockTranslateService
mockTranslateService,
{} // default empty session config
);

spyOn(sessionService, "logout");
Expand Down Expand Up @@ -884,7 +885,7 @@ class SessionServiceHelper extends StarkSessionServiceImpl {
idle: Idle,
injector: Injector,
translateService: TranslateService,
sessionConfig?: StarkSessionConfig
sessionConfig: StarkSessionConfig
) {
super(store, logger, routingService, appConfig, idle, injector, translateService, sessionConfig);
}
Expand Down
Loading