Skip to content

Commit

Permalink
refactor(auth-js)!: rename loadSession option to loadUserSession
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `loadSession` option was renamed to `loadUserSession`
  • Loading branch information
Badisi committed Apr 19, 2022
1 parent de004c2 commit cd00c9b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion projects/auth-js/oidc/models/oidc-auth-settings.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface OIDCAuthSettings extends CoreAuthSettings, Pick<UserManagerSett
authorityUrl: string;
clientId: string;
schemeUri?: string;
loadSession?: boolean;
loadUserSession?: boolean;
navigationType?: Navigation;
logLevel?: Log;
internal?: Partial<Omit<UserManagerSettings, UsefulSettings | 'authority' | 'client_id'>>;
Expand Down
4 changes: 2 additions & 2 deletions projects/auth-js/oidc/oidc-auth-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const REDIRECT_URL_KEY = 'auth-js:oidc_manager:redirect_url';

const DEFAULT_SETTINGS: Optional<OIDCAuthSettings, 'authorityUrl' | 'clientId'> = {
loginRequired: false,
loadSession: true,
loadUserSession: true,
loadUserInfo: false,
automaticSilentRenew: true,
navigationType: Navigation.REDIRECT,
Expand Down Expand Up @@ -152,7 +152,7 @@ export class OIDCAuthManager extends AuthManager<OIDCAuthSettings> {
await runSyncOrAsync(() => this.backFromLogin());
} else if (this.urlMatching(location.href, this.settings.internal?.post_logout_redirect_uri)) {
await runSyncOrAsync(() => this.backFromLogout());
} else if (this.settings.loadSession) {
} else if (this.settings.loadUserSession) {
await runSyncOrAsync(() => this.signinSilent().catch(async (signinSilentError: Error) => {
if (this.settings.loginRequired) {
if (signinSilentError.message === 'login_required') {
Expand Down
10 changes: 5 additions & 5 deletions projects/demo-app/auth-js/src/app/app.settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const settings: Settings<OIDCAuthSettings>[] = [{
navigationType: Navigation.REDIRECT,
logLevel: Log.NONE,
loginRequired: false,
loadSession: true,
loadUserSession: true,
loadUserInfo: true,
automaticSilentRenew: true
}
Expand All @@ -32,7 +32,7 @@ const settings: Settings<OIDCAuthSettings>[] = [{
navigationType: Navigation.REDIRECT,
logLevel: Log.NONE,
loginRequired: false,
loadSession: true,
loadUserSession: true,
loadUserInfo: true,
automaticSilentRenew: true
}
Expand Down Expand Up @@ -98,12 +98,12 @@ const librarySettingsDefinition: LibrarySettingsDefinitionItem<OIDCAuthSettings>
label: 'Login required',
type: 'boolean'
}, {
name: 'loadSession',
label: 'Load session',
name: 'loadUserSession',
label: 'Load user\'s session',
type: 'boolean'
}, {
name: 'loadUserInfo',
label: 'Load user info',
label: 'Load user\'s info',
type: 'boolean'
}, {
name: 'automaticSilentRenew',
Expand Down
10 changes: 5 additions & 5 deletions projects/demo-app/ngx-auth/src/app/app.settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const settings: Settings<AuthSettings>[] = [{
navigationType: Navigation.REDIRECT,
logLevel: Log.NONE,
loginRequired: false,
loadSession: true,
loadUserSession: true,
loadUserInfo: true,
automaticSilentRenew: true,
automaticLoginOn401: true,
Expand All @@ -47,7 +47,7 @@ const settings: Settings<AuthSettings>[] = [{
navigationType: Navigation.REDIRECT,
logLevel: Log.NONE,
loginRequired: false,
loadSession: true,
loadUserSession: true,
loadUserInfo: true,
automaticSilentRenew: true,
automaticLoginOn401: true,
Expand Down Expand Up @@ -119,12 +119,12 @@ const librarySettingsDefinition: LibrarySettingsDefinitionItem<AuthSettings>[] =
label: 'Login required',
type: 'boolean'
}, {
name: 'loadSession',
label: 'Load session',
name: 'loadUserSession',
label: 'Load user\'s session',
type: 'boolean'
}, {
name: 'loadUserInfo',
label: 'Load user info',
label: 'Load user\'s info',
type: 'boolean'
}, {
name: 'automaticSilentRenew',
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-auth/schematics/install/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const getActualUserConfig = async (context: SchematicContext, options: InstallOp
authorityUrl: options.authorityUrl,
clientId: options.clientId
};
(['loginRequired', 'loadSession', 'loadUserInfo'] as (keyof InstallOptions)[]).forEach(name => {
(['loginRequired', 'loadUserSession', 'loadUserInfo'] as (keyof InstallOptions)[]).forEach(name => {
if (options[name] !== defaultOptions[name]) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
(config as any)[name] = options[name];
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-auth/schematics/install/install-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ export class InstallOptions {
public authorityUrl!: string;
public clientId!: string;
public loginRequired?: boolean;
public loadSession?: boolean;
public loadUserSession?: boolean;
public loadUserInfo?: boolean;
}
2 changes: 1 addition & 1 deletion projects/ngx-auth/schematics/install/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"type": "boolean",
"default": false
},
"loadSession": {
"loadUserSession": {
"x-prompt": "Retrieve user's session at startup ?",
"description": "Whether any currently opened user's session should be retrieved during the initialization phase.",
"type": "boolean",
Expand Down
2 changes: 1 addition & 1 deletion projects/site/docs/docs/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ await initAuth(settings: AuthSettings);
> **type**: boolean<br/>
> **default**: true
### `loadSession`
### `loadUserSession`
> **type**: boolean<br/>
> **default**: true
Expand Down

0 comments on commit cd00c9b

Please sign in to comment.