Merge pull request #3232 from dpalou/MOBILE-4022

MOBILE-4022 core: Use new setting autologinmintimebetweenreq
main
Pau Ferrer Ocaña 2022-04-05 16:08:00 +02:00 committed by GitHub
commit fd65509190
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 3 deletions

View File

@ -1746,12 +1746,23 @@ export class CoreSite {
* @return Promise resolved with the converted URL.
*/
async getAutoLoginUrl(url: string, showModal: boolean = true): Promise<string> {
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,