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
5 changes: 3 additions & 2 deletions www/addons/files/controllers/choosesite.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ angular.module('mm.addons.files')
* @ngdoc controller
* @name mmaFilesChooseSiteCtrl
*/
.controller('mmaFilesChooseSiteCtrl', function($scope, $state, $stateParams, $mmSitesManager, $mmaFilesHelper, $ionicHistory) {
.controller('mmaFilesChooseSiteCtrl', function($scope, $stateParams, $mmSitesManager, $mmaFilesHelper, $ionicHistory,
$mmLoginHelper) {

var fileEntry = $stateParams.file || {};
$scope.filename = fileEntry.name;
Expand All @@ -35,7 +36,7 @@ angular.module('mm.addons.files')
$ionicHistory.nextViewOptions({
disableBack: true
});
$state.go('site.mm_courses');
$mmLoginHelper.goToSiteInitialPage();
});
};
});
4 changes: 2 additions & 2 deletions www/core/components/login/controllers/credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ angular.module('mm.core.login')
// Action should only have 1 site because we're filtering by username.
action.action(action.sites[0]);
} else {
$state.go('site.mm_courses');
return $mmLoginHelper.goToSiteInitialPage();
}
});
} else {
$state.go('site.mm_courses');
return $mmLoginHelper.goToSiteInitialPage();
}
});
}).catch(function(error) {
Expand Down
2 changes: 1 addition & 1 deletion www/core/components/login/controllers/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ angular.module('mm.core.login')
});

if ($mmSite.isLoggedIn()) {
$state.go('site.mm_courses');
$mmLoginHelper.goToSiteInitialPage();
} else {
$mmSitesManager.hasSites().then(function() {
return $state.go('mm_login.sites');
Expand Down
5 changes: 3 additions & 2 deletions www/core/components/login/controllers/reconnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ angular.module('mm.core.login')
* @ngdoc controller
* @name mmLoginReconnectCtrl
*/
.controller('mmLoginReconnectCtrl', function($scope, $state, $stateParams, $mmSitesManager, $mmApp, $mmUtil, $ionicHistory) {
.controller('mmLoginReconnectCtrl', function($scope, $state, $stateParams, $mmSitesManager, $mmApp, $mmUtil, $ionicHistory,
$mmLoginHelper) {

var infositeurl = $stateParams.infositeurl; // Siteurl in site info. It might be different than siteurl (http/https).
$scope.siteurl = $stateParams.siteurl;
Expand Down Expand Up @@ -63,7 +64,7 @@ angular.module('mm.core.login')
$mmSitesManager.updateSiteInfoByUrl(infositeurl, username).finally(function() {
delete $scope.credentials; // Delete password from the scope.
$ionicHistory.nextViewOptions({disableBack: true});
$state.go('site.mm_courses');
return $mmLoginHelper.goToSiteInitialPage();
});
}, function(error) {
// Site deleted? Go back to login page.
Expand Down
2 changes: 1 addition & 1 deletion www/core/components/login/controllers/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ angular.module('mm.core.login')
$mmSitesManager.getUserToken(sitedata.url, sitedata.username, sitedata.password).then(function(data) {
$mmSitesManager.newSite(data.siteurl, data.token).then(function() {
$ionicHistory.nextViewOptions({disableBack: true});
$state.go('site.mm_courses');
return $mmLoginHelper.goToSiteInitialPage();
}, function(error) {
$mmUtil.showErrorModal(error);
}).finally(function() {
Expand Down
2 changes: 1 addition & 1 deletion www/core/components/login/controllers/sites.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ angular.module('mm.core.login')

$mmSitesManager.loadSite(siteid).then(function() {
$ionicHistory.nextViewOptions({disableBack: true});
$state.go('site.mm_courses');
return $mmLoginHelper.goToSiteInitialPage();
}, function(error) {
$log.error('Error loading site '+siteid);
error = error || 'Error loading site.';
Expand Down
4 changes: 2 additions & 2 deletions www/core/components/login/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ angular.module('mm.core.login', [])
disableAnimate: true,
disableBack: true
});
$state.transitionTo('site.mm_courses');
$mmLoginHelper.goToSiteInitialPage();
}

});
Expand Down Expand Up @@ -202,7 +202,7 @@ angular.module('mm.core.login', [])
$mmLoginHelper.validateBrowserSSOLogin(url).then(function(sitedata) {

$mmLoginHelper.handleSSOLoginAuthentication(sitedata.siteurl, sitedata.token).then(function() {
$state.go('site.mm_courses');
return $mmLoginHelper.goToSiteInitialPage();
}, function(error) {
$mmUtil.showErrorModal(error);
}).finally(function() {
Expand Down
22 changes: 21 additions & 1 deletion www/core/components/login/services/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ angular.module('mm.core.login')
* @name $mmLoginHelper
*/
.factory('$mmLoginHelper', function($q, $log, $mmConfig, mmLoginSSOCode, mmLoginLaunchSiteURL, mmLoginLaunchPassport,
md5, $mmSite, $mmSitesManager, $mmLang, $mmUtil, $state, mmCoreConfigConstants) {
md5, $mmSite, $mmSitesManager, $mmLang, $mmUtil, $state, $mmAddonManager, mmCoreConfigConstants) {

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

Expand All @@ -50,6 +50,26 @@ angular.module('mm.core.login')
}
};

/**
* Go to the initial page of a site depending on 'userhomepage' setting.
*
* @module mm.core.login
* @ngdoc method
* @name $mmLoginHelper#goToSiteInitialPage
* @return {Promise} Promise resolved when the state changes.
*/
self.goToSiteInitialPage = function() {
if ($mmSite.getInfo() && $mmSite.getInfo().userhomepage === 0) {
// Configured to go to Site Home. Check if plugin is installed in the app.
var $mmaFrontpage = $mmAddonManager.get('$mmaFrontpage');
if ($mmaFrontpage) {
return $state.go('site.mm_course-section');
}
}

return $state.go('site.mm_courses');
};

/**
* Check if the app is configured to use a fixed URL.
*
Expand Down