Add config types and utility function for SSO redirect config (#6976)
* Add config types and utility function for SSO redirect config * Appease the linter
This commit is contained in:
parent
c73127c35c
commit
bc32f05fcb
1 changed files with 21 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright 2016 OpenMarket Ltd
|
||||
Copyright 2019, 2020 The Matrix.org Foundation C.I.C.
|
||||
Copyright 2019 - 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -15,8 +15,17 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
export interface ISsoRedirectOptions {
|
||||
immediate?: boolean;
|
||||
on_welcome_page?: boolean; // eslint-disable-line camelcase
|
||||
}
|
||||
|
||||
export interface ConfigOptions {
|
||||
[key: string]: any;
|
||||
|
||||
// sso_immediate_redirect is deprecated in favour of sso_redirect_options.immediate
|
||||
sso_immediate_redirect?: boolean; // eslint-disable-line camelcase
|
||||
sso_redirect_options?: ISsoRedirectOptions; // eslint-disable-line camelcase
|
||||
}
|
||||
|
||||
export const DEFAULTS: ConfigOptions = {
|
||||
|
@ -74,3 +83,14 @@ export default class SdkConfig {
|
|||
SdkConfig.put(newConfig);
|
||||
}
|
||||
}
|
||||
|
||||
export function parseSsoRedirectOptions(config: ConfigOptions): ISsoRedirectOptions {
|
||||
// Ignore deprecated options if the config is using new ones
|
||||
if (config.sso_redirect_options) return config.sso_redirect_options;
|
||||
|
||||
// We can cheat here because the default is false anyways
|
||||
if (config.sso_immediate_redirect) return { immediate: true };
|
||||
|
||||
// Default: do nothing
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue