@@ -106,22 +106,6 @@ export class CoreLoginHelperProvider {
106106 this . cleanUpPasswordResets ( ) ;
107107 }
108108
109- /**
110- * Check if a site allows requesting a password reset through the app.
111- *
112- * @param siteUrl URL of the site.
113- * @returns Promise resolved with boolean: whether can be done through the app.
114- */
115- async canRequestPasswordReset ( siteUrl : string ) : Promise < boolean > {
116- try {
117- await this . requestPasswordReset ( siteUrl ) ;
118-
119- return true ;
120- } catch ( error ) {
121- return error . available == 1 || ( error . errorcode && error . errorcode != 'invalidrecord' ) ;
122- }
123- }
124-
125109 /**
126110 * Function called when an SSO InAppBrowser is closed or the app is resumed. Check if user needs to be logged out.
127111 */
@@ -157,19 +141,13 @@ export class CoreLoginHelperProvider {
157141 const modal = await CoreLoadings . show ( ) ;
158142
159143 try {
160- const canReset = await this . canRequestPasswordReset ( siteUrl ) ;
161-
162- if ( canReset ) {
163- await CoreNavigator . navigate ( '/login/forgottenpassword' , {
164- params : {
165- siteUrl,
166- siteConfig,
167- username,
168- } ,
169- } ) ;
170- } else {
171- this . openForgottenPassword ( siteUrl ) ;
172- }
144+ await CoreNavigator . navigate ( '/login/forgottenpassword' , {
145+ params : {
146+ siteUrl,
147+ siteConfig,
148+ username,
149+ } ,
150+ } ) ;
173151 } finally {
174152 modal . dismiss ( ) ;
175153 }
@@ -196,7 +174,7 @@ export class CoreLoginHelperProvider {
196174 site = site || CoreSites . getCurrentSite ( ) ;
197175 const config = site ?. getStoredConfig ( ) ;
198176
199- return `core.mainmenu.${ config && config . tool_mobile_forcelogout == '1' ? 'logout' : 'switchaccount' } ` ;
177+ return `core.mainmenu.${ config && config . tool_mobile_forcelogout === '1' ? 'logout' : 'switchaccount' } ` ;
200178 }
201179
202180 /**
@@ -402,8 +380,11 @@ export class CoreLoginHelperProvider {
402380
403381 return sites . some ( ( site ) => CoreUrl . sameDomainAndPath ( siteUrl , site . url ) ) ||
404382 ( ! ! demoModeSite && CoreUrl . sameDomainAndPath ( siteUrl , demoModeSite . url ) ) ;
405- } else if ( CoreConstants . CONFIG . multisitesdisplay == 'sitefinder' && CoreConstants . CONFIG . onlyallowlistedsites &&
406- checkSiteFinder ) {
383+ } else if (
384+ CoreConstants . CONFIG . multisitesdisplay === CoreLoginSiteSelectorListMethod . SITE_FINDER &&
385+ CoreConstants . CONFIG . onlyallowlistedsites &&
386+ checkSiteFinder
387+ ) {
407388 // Call the sites finder to validate the site.
408389 const result = await CoreSites . findSites ( siteUrl . replace ( / ^ h t t p s ? : \/ \/ | \. \w { 2 , 3 } \/ ? $ / g, '' ) ) ;
409390
@@ -418,20 +399,20 @@ export class CoreLoginHelperProvider {
418399 * Check if SSO login should use an embedded browser.
419400 *
420401 * @param code Code to check.
421- * @returns True if embedded browser, false othwerise .
402+ * @returns True if embedded browser, false otherwise .
422403 */
423404 isSSOEmbeddedBrowser ( code : TypeOfLogin ) : boolean {
424- return code == TypeOfLogin . EMBEDDED ;
405+ return code === TypeOfLogin . EMBEDDED ;
425406 }
426407
427408 /**
428409 * Check if SSO login is needed based on code returned by the WS.
429410 *
430411 * @param code Code to check.
431- * @returns True if SSO login is needed, false othwerise .
412+ * @returns True if SSO login is needed, false otherwise .
432413 */
433414 isSSOLoginNeeded ( code : TypeOfLogin ) : boolean {
434- return code == TypeOfLogin . BROWSER || code == TypeOfLogin . EMBEDDED ;
415+ return code === TypeOfLogin . BROWSER || code = == TypeOfLogin . EMBEDDED ;
435416 }
436417
437418 /**
@@ -541,15 +522,6 @@ export class CoreLoginHelperProvider {
541522 CoreOpener . openInApp ( `${ siteUrl } /login/change_password.php` ) ;
542523 }
543524
544- /**
545- * Open forgotten password in inappbrowser.
546- *
547- * @param siteUrl URL of the site.
548- */
549- openForgottenPassword ( siteUrl : string ) : void {
550- CoreOpener . openInApp ( `${ siteUrl } /login/forgot_password.php` ) ;
551- }
552-
553525 /**
554526 * Function to open in app browser to change password or complete user profile.
555527 *
@@ -815,6 +787,8 @@ export class CoreLoginHelperProvider {
815787
816788 /**
817789 * Show a modal warning that the credentials introduced were not correct.
790+ *
791+ * @param error Error object.
818792 */
819793 protected showInvalidLoginModal ( error : CoreError ) : void {
820794 const errorDetails = error instanceof CoreSiteError ? error . debug ?. details : null ;
@@ -995,17 +969,17 @@ export class CoreLoginHelperProvider {
995969
996970 // Validate the signature.
997971 // We need to check both http and https.
998- let signature = Md5 . hashAsciiStr ( launchSiteURL + passport ) ;
999- if ( signature != params [ 0 ] ) {
1000- if ( launchSiteURL . indexOf ( 'https://' ) != - 1 ) {
972+ let signature : string = Md5 . hashAsciiStr ( launchSiteURL + passport ) ;
973+ if ( signature !== params [ 0 ] ) {
974+ if ( launchSiteURL . includes ( 'https://' ) ) {
1001975 launchSiteURL = launchSiteURL . replace ( 'https://' , 'http://' ) ;
1002976 } else {
1003977 launchSiteURL = launchSiteURL . replace ( 'http://' , 'https://' ) ;
1004978 }
1005979 signature = Md5 . hashAsciiStr ( launchSiteURL + passport ) ;
1006980 }
1007981
1008- if ( signature == params [ 0 ] ) {
982+ if ( signature === params [ 0 ] ) {
1009983 this . logger . debug ( 'Signature validated' ) ;
1010984
1011985 return {
@@ -1131,7 +1105,7 @@ export class CoreLoginHelperProvider {
11311105 // Not a custom URL scheme, check if it's a URL scheme to another app.
11321106 const scheme = CoreUrl . getUrlProtocol ( text ) ;
11331107
1134- if ( scheme && scheme != 'http' && scheme != 'https' ) {
1108+ if ( scheme && scheme !== 'http' && scheme != = 'https' ) {
11351109 CoreAlerts . showError ( Translate . instant ( 'core.errorurlschemeinvalidscheme' , { $a : text } ) ) ;
11361110 } else {
11371111 CoreAlerts . showError ( Translate . instant ( 'core.login.errorqrnoscheme' ) ) ;
@@ -1155,7 +1129,7 @@ export class CoreLoginHelperProvider {
11551129 let siteUrl = '' ;
11561130
11571131 if ( currentSiteId ) {
1158- siteUrl = sites . find ( ( site ) => site . id == currentSiteId ) ?. siteUrlWithoutProtocol ?? '' ;
1132+ siteUrl = sites . find ( ( site ) => site . id === currentSiteId ) ?. siteUrlWithoutProtocol ?? '' ;
11591133 }
11601134
11611135 const otherSites : Record < string , CoreSiteBasicInfo [ ] > = { } ;
@@ -1166,7 +1140,7 @@ export class CoreLoginHelperProvider {
11661140
11671141 if ( site . id === currentSiteId ) {
11681142 accountsList . currentSite = site ;
1169- } else if ( site . siteUrlWithoutProtocol == siteUrl ) {
1143+ } else if ( site . siteUrlWithoutProtocol === siteUrl ) {
11701144 accountsList . sameSite . push ( site ) ;
11711145 } else {
11721146 if ( ! otherSites [ site . siteUrlWithoutProtocol ] ) {
@@ -1197,8 +1171,8 @@ export class CoreLoginHelperProvider {
11971171 let index = 0 ;
11981172
11991173 // Found on same site.
1200- if ( accountsList . sameSite . length > 0 && accountsList . sameSite [ 0 ] . siteUrlWithoutProtocol == siteUrl ) {
1201- index = accountsList . sameSite . findIndex ( ( listedSite ) => listedSite . id == site . id ) ;
1174+ if ( accountsList . sameSite . length > 0 && accountsList . sameSite [ 0 ] . siteUrlWithoutProtocol === siteUrl ) {
1175+ index = accountsList . sameSite . findIndex ( ( listedSite ) => listedSite . id === site . id ) ;
12021176 if ( index >= 0 ) {
12031177 accountsList . sameSite . splice ( index , 1 ) ;
12041178 accountsList . count -- ;
@@ -1208,19 +1182,19 @@ export class CoreLoginHelperProvider {
12081182 }
12091183
12101184 const otherSiteIndex = accountsList . otherSites . findIndex ( ( sites ) =>
1211- sites . length > 0 && sites [ 0 ] . siteUrlWithoutProtocol == siteUrl ) ;
1185+ sites . length > 0 && sites [ 0 ] . siteUrlWithoutProtocol === siteUrl ) ;
12121186 if ( otherSiteIndex < 0 ) {
12131187 // Site Url not found.
12141188 return ;
12151189 }
12161190
1217- index = accountsList . otherSites [ otherSiteIndex ] . findIndex ( ( listedSite ) => listedSite . id == site . id ) ;
1191+ index = accountsList . otherSites [ otherSiteIndex ] . findIndex ( ( listedSite ) => listedSite . id === site . id ) ;
12181192 if ( index >= 0 ) {
12191193 accountsList . otherSites [ otherSiteIndex ] . splice ( index , 1 ) ;
12201194 accountsList . count -- ;
12211195 }
12221196
1223- if ( accountsList . otherSites [ otherSiteIndex ] . length == 0 ) {
1197+ if ( ! accountsList . otherSites [ otherSiteIndex ] . length ) {
12241198 accountsList . otherSites . splice ( otherSiteIndex , 1 ) ;
12251199 }
12261200 }
@@ -1400,11 +1374,12 @@ type StoredLoginLaunchData = CoreRedirectPayload & {
14001374 ssoUrlParams : CoreUrlParams ;
14011375} ;
14021376
1403- export type CoreLoginSiteSelectorListMethod =
1404- 'url' |
1405- 'sitefinder' |
1406- 'list' |
1407- '' ;
1377+ export const enum CoreLoginSiteSelectorListMethod {
1378+ URL = 'url' ,
1379+ SITE_FINDER = 'sitefinder' ,
1380+ LIST = 'list' ,
1381+ NONE = '' ,
1382+ }
14081383
14091384export type CoreLoginMethod = {
14101385 name : string ; // Name of the login method.
0 commit comments