Skip to content

Commit

Permalink
Merge pull request #766 from christophercr/feature/configurable-sessi…
Browse files Browse the repository at this point in the history
…on-states

feat(stark-core): allow customizing Login and Preloading states via the StarkSessionConfig
  • Loading branch information
SuperITMan authored Oct 19, 2018
2 parents 6218046 + f8112cb commit 822dec2
Show file tree
Hide file tree
Showing 17 changed files with 260 additions and 179 deletions.
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

0 comments on commit 822dec2

Please sign in to comment.