From e8c94a3a80016d999751ee803448544c985e17b8 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 5 Apr 2022 15:52:24 +0200 Subject: [PATCH] MOBILE-4022 core: Use new setting autologinmintimebetweenreq --- src/core/classes/site.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/core/classes/site.ts b/src/core/classes/site.ts index dc2644d60..693830b19 100644 --- a/src/core/classes/site.ts +++ b/src/core/classes/site.ts @@ -1746,12 +1746,23 @@ export class CoreSite { * @return Promise resolved with the converted URL. */ async getAutoLoginUrl(url: string, showModal: boolean = true): Promise { - if (!this.privateToken || (this.lastAutoLogin && - CoreTimeUtils.timestamp() - this.lastAutoLogin < CoreConstants.SECONDS_MINUTE * 6)) { - // No private token, WS not available or last auto-login was less than 6 minutes ago. Don't change the URL. + if (!this.privateToken) { + // No private token, don't change the URL. return url; } + if (this.lastAutoLogin > 0) { + const timeBetweenRequests = await CoreUtils.ignoreErrors( + this.getConfig('tool_mobile_autologinmintimebetweenreq'), + CoreConstants.SECONDS_MINUTE * 6, + ); + + if (CoreTimeUtils.timestamp() - this.lastAutoLogin < timeBetweenRequests) { + // Not enough time has passed since last auto login. + return url; + } + } + const userId = this.getUserId(); const params = { privatetoken: this.privateToken,