MOBILE-4201 login: Add TypeOfLogin enum

main
Pau Ferrer Ocaña 2023-09-14 16:43:27 +02:00
parent a0c0162b85
commit a4d7ffeb5e
3 changed files with 27 additions and 12 deletions

View File

@ -2771,7 +2771,7 @@ export type CoreSitePublicConfigResponse = {
maintenancemessage: string; // Maintenance message. maintenancemessage: string; // Maintenance message.
logourl?: string; // The site logo URL. logourl?: string; // The site logo URL.
compactlogourl?: string; // The site compact logo URL. compactlogourl?: string; // The site compact logo URL.
typeoflogin: number; // The type of login. 1 for app, 2 for browser, 3 for embedded. typeoflogin: TypeOfLogin; // The type of login. 1 for app, 2 for browser, 3 for embedded.
launchurl?: string; // SSO login launch URL. launchurl?: string; // SSO login launch URL.
mobilecssurl?: string; // Mobile custom CSS theme. mobilecssurl?: string; // Mobile custom CSS theme.
// eslint-disable-next-line @typescript-eslint/naming-convention // eslint-disable-next-line @typescript-eslint/naming-convention
@ -2869,3 +2869,12 @@ enum OngoingRequestType {
STANDARD = 0, STANDARD = 0,
UPDATE_IN_BACKGROUND = 1, UPDATE_IN_BACKGROUND = 1,
} }
/**
* The type of login. 1 for app, 2 for browser, 3 for embedded.
*/
export enum TypeOfLogin {
APP = 1,
BROWSER = 2, // SSO in browser window is required.
EMBEDDED = 3, // SSO in embedded browser is required.
}

View File

@ -82,7 +82,13 @@ export class CoreConstants {
static readonly WS_PREFIX = 'local_mobile_'; // @deprecated since app 4.0. static readonly WS_PREFIX = 'local_mobile_'; // @deprecated since app 4.0.
// Login constants. // Login constants.
/**
* @deprecated since 4.3 Use TypeOfLogin.BROWSER instead.
*/
static readonly LOGIN_SSO_CODE = 2; // SSO in browser window is required. static readonly LOGIN_SSO_CODE = 2; // SSO in browser window is required.
/**
* @deprecated since 4.3 Use TypeOfLogin.EMBEDDED instead.
*/
static readonly LOGIN_SSO_INAPP_CODE = 3; // SSO in embedded browser is required. static readonly LOGIN_SSO_INAPP_CODE = 3; // SSO in embedded browser is required.
static readonly LOGIN_LAUNCH_DATA = 'CoreLoginLaunchData'; static readonly LOGIN_LAUNCH_DATA = 'CoreLoginLaunchData';

View File

@ -26,7 +26,7 @@ import { CoreTextUtils } from '@services/utils/text';
import { CoreUrlParams, CoreUrlUtils } from '@services/utils/url'; import { CoreUrlParams, CoreUrlUtils } from '@services/utils/url';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreConstants } from '@/core/constants'; import { CoreConstants } from '@/core/constants';
import { CoreSite, CoreSiteIdentityProvider, CoreSitePublicConfigResponse, CoreSiteQRCodeType } from '@classes/site'; import { CoreSite, CoreSiteIdentityProvider, CoreSitePublicConfigResponse, CoreSiteQRCodeType, TypeOfLogin } from '@classes/site';
import { CoreError } from '@classes/errors/error'; import { CoreError } from '@classes/errors/error';
import { CoreWSError } from '@classes/errors/wserror'; import { CoreWSError } from '@classes/errors/wserror';
import { DomSanitizer, makeSingleton, Translate } from '@singletons'; import { DomSanitizer, makeSingleton, Translate } from '@singletons';
@ -139,7 +139,7 @@ export class CoreLoginHelperProvider {
* Open a browser to perform SSO login. * Open a browser to perform SSO login.
* *
* @param siteUrl URL of the site where the SSO login will be performed. * @param siteUrl URL of the site where the SSO login will be performed.
* @param typeOfLogin CoreConstants.LOGIN_SSO_CODE or CoreConstants.LOGIN_SSO_INAPP_CODE. * @param typeOfLogin TypeOfLogin.BROWSER or TypeOfLogin.EMBEDDED.
* @param service The service to use. If not defined, core service will be used. * @param service The service to use. If not defined, core service will be used.
* @param launchUrl The URL to open for SSO. If not defined, default tool mobile launch URL will be used. * @param launchUrl The URL to open for SSO. If not defined, default tool mobile launch URL will be used.
* @param redirectData Data of the path/url to open once authenticated. If not defined, site initial page. * @param redirectData Data of the path/url to open once authenticated. If not defined, site initial page.
@ -148,7 +148,7 @@ export class CoreLoginHelperProvider {
*/ */
async confirmAndOpenBrowserForSSOLogin( async confirmAndOpenBrowserForSSOLogin(
siteUrl: string, siteUrl: string,
typeOfLogin: number, typeOfLogin: TypeOfLogin,
service?: string, service?: string,
launchUrl?: string, launchUrl?: string,
redirectData?: CoreRedirectPayload, redirectData?: CoreRedirectPayload,
@ -601,8 +601,8 @@ export class CoreLoginHelperProvider {
* @param code Code to check. * @param code Code to check.
* @returns True if embedded browser, false othwerise. * @returns True if embedded browser, false othwerise.
*/ */
isSSOEmbeddedBrowser(code: number): boolean { isSSOEmbeddedBrowser(code: TypeOfLogin): boolean {
return code == CoreConstants.LOGIN_SSO_INAPP_CODE; return code == TypeOfLogin.EMBEDDED;
} }
/** /**
@ -611,8 +611,8 @@ export class CoreLoginHelperProvider {
* @param code Code to check. * @param code Code to check.
* @returns True if SSO login is needed, false othwerise. * @returns True if SSO login is needed, false othwerise.
*/ */
isSSOLoginNeeded(code: number): boolean { isSSOLoginNeeded(code: TypeOfLogin): boolean {
return code == CoreConstants.LOGIN_SSO_CODE || code == CoreConstants.LOGIN_SSO_INAPP_CODE; return code == TypeOfLogin.BROWSER || code == TypeOfLogin.EMBEDDED;
} }
/** /**
@ -656,14 +656,14 @@ export class CoreLoginHelperProvider {
* Open a browser to perform SSO login. * Open a browser to perform SSO login.
* *
* @param siteUrl URL of the site where the SSO login will be performed. * @param siteUrl URL of the site where the SSO login will be performed.
* @param typeOfLogin CoreConstants.LOGIN_SSO_CODE or CoreConstants.LOGIN_SSO_INAPP_CODE. * @param typeOfLogin TypeOfLogin.BROWSER or TypeOfLogin.EMBEDDED.
* @param service The service to use. If not defined, core service will be used. * @param service The service to use. If not defined, core service will be used.
* @param launchUrl The URL to open for SSO. If not defined, default tool mobile launch URL will be used. * @param launchUrl The URL to open for SSO. If not defined, default tool mobile launch URL will be used.
* @param redirectData Data of the path/url to open once authenticated. If not defined, site initial page. * @param redirectData Data of the path/url to open once authenticated. If not defined, site initial page.
*/ */
openBrowserForSSOLogin( openBrowserForSSOLogin(
siteUrl: string, siteUrl: string,
typeOfLogin: number, typeOfLogin: TypeOfLogin,
service?: string, service?: string,
launchUrl?: string, launchUrl?: string,
redirectData?: CoreRedirectPayload, redirectData?: CoreRedirectPayload,
@ -901,12 +901,12 @@ export class CoreLoginHelperProvider {
/** /**
* Check if a confirm should be shown to open a SSO authentication. * Check if a confirm should be shown to open a SSO authentication.
* *
* @param typeOfLogin CoreConstants.LOGIN_SSO_CODE or CoreConstants.LOGIN_SSO_INAPP_CODE. * @param typeOfLogin TypeOfLogin.BROWSER or TypeOfLogin.EMBEDDED.
* @returns True if confirm modal should be shown, false otherwise. * @returns True if confirm modal should be shown, false otherwise.
* @deprecated since 4.3 Not used anymore. * @deprecated since 4.3 Not used anymore.
*/ */
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
shouldShowSSOConfirm(typeOfLogin: number): boolean { shouldShowSSOConfirm(typeOfLogin: TypeOfLogin): boolean {
return false; return false;
} }