Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions www/core/components/login/controllers/credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ angular.module('mm.core.login')
if ($mmLoginHelper.isSSOLoginNeeded(result.code)) {
// SSO. User needs to authenticate in a browser.
$scope.isBrowserSSO = true;
$mmUtil.showConfirm($translate('mm.login.logininsiterequired')).then(function() {
$mmLoginHelper.openBrowserForSSOLogin(result.siteurl);
});

// Check that there's no SSO authentication ongoing and the view hasn't changed.
if (!$mmLoginHelper.isSSOLoginOngoing() && !$scope.$$destroyed) {
$mmUtil.showConfirm($translate('mm.login.logininsiterequired')).then(function() {
$mmLoginHelper.openBrowserForSSOLogin(result.siteurl);
});
}
} else {
$scope.isBrowserSSO = false;
}
Expand Down
15 changes: 7 additions & 8 deletions www/core/components/login/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ angular.module('mm.core.login', [])
}

// App opened using custom URL scheme. Probably an SSO authentication.
$mmLoginHelper.setSSOLoginOngoing(true);
$log.debug('App launched by URL');

var modal = $mmUtil.showModalLoading('mm.login.authenticating', true);
Expand All @@ -201,19 +202,17 @@ angular.module('mm.core.login', [])

$mmLoginHelper.validateBrowserSSOLogin(url).then(function(sitedata) {

$mmLoginHelper.handleSSOLoginAuthentication(sitedata.siteurl, sitedata.token).then(function() {
return $mmLoginHelper.handleSSOLoginAuthentication(sitedata.siteurl, sitedata.token).then(function() {
return $mmLoginHelper.goToSiteInitialPage();
}, function(error) {
$mmUtil.showErrorModal(error);
}).finally(function() {
modal.dismiss();
});

}, function(errorMessage) {
modal.dismiss();
if (typeof(errorMessage) === 'string' && errorMessage != '') {
}).catch(function(errorMessage) {
if (typeof errorMessage === 'string' && errorMessage !== '') {
$mmUtil.showErrorModal(errorMessage);
}
}).finally(function() {
modal.dismiss();
$mmLoginHelper.setSSOLoginOngoing(false);
});

return true;
Expand Down
29 changes: 28 additions & 1 deletion www/core/components/login/services/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ angular.module('mm.core.login')

$log = $log.getInstance('$mmLoginHelper');

var self = {};
var self = {},
isSSOLoginOngoing = false;

/**
* Go to the view to add a new site.
Expand Down Expand Up @@ -95,6 +96,19 @@ angular.module('mm.core.login')
return code == mmLoginSSOCode;
};

/**
* Check if there's an SSO authentication ongoing. This should be true if the app was opened by a browser because of
* a SSO login and the authentication hasn't finished yet.
*
* @module mm.core.login
* @ngdoc method
* @name $mmLoginHelper#isSSOLoginOngoing
* @return {Boolean} True if SSO is ongoing, false otherwise.
*/
self.isSSOLoginOngoing = function() {
return isSSOLoginOngoing;
};

/**
* Open a browser to perform SSO login.
*
Expand All @@ -119,6 +133,19 @@ angular.module('mm.core.login')
}
};

/**
* Set the "SSO authentication ongoing" flag to true or false.
*
* @module mm.core.login
* @ngdoc method
* @name $mmLoginHelper#setSSOLoginOngoing
* @param {Boolean} value Value to set.
* @return {Void}
*/
self.setSSOLoginOngoing = function(value) {
isSSOLoginOngoing = value;
};

/**
* Convenient helper to validate a browser SSO login.
*
Expand Down