Skip to content

Commit

Permalink
Handling situation with missing trailing slash.
Browse files Browse the repository at this point in the history
  • Loading branch information
kiarn committed Feb 13, 2023
1 parent c34edd6 commit e3cc669
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions plugins/core/resources/js/core/controllers/login.controller.es
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ angular.module('core').controller('CoreLoginController', function($scope, $log,

$scope.sanitizeNextPage = () => {
// Avoid some unwanted redirections
if ($routeParams.nextPage.substring(0,1) != '/') {
return '/';
} else {
return $routeParams.nextPage;
if ($routeParams.nextPage !== undefined) {
if ($routeParams.nextPage.substring(0, 1) != '/') {
return '/'
} else {
return $routeParams.nextPage
}
}
return '/'
}

$scope.verify = ($event) => {
Expand All @@ -31,7 +34,8 @@ angular.module('core').controller('CoreLoginController', function($scope, $log,
$scope.totp_attempts++;
identity.auth($scope.username, code, "totp").then((response) => {
$scope.success = true;
location.href = customization.plugins.core.loginredir || $scope.sanitizeNextPage() || '/';
nextPage = $scope.sanitizeNextPage();
location.href = customization.plugins.core.loginredir || nextPage;
}, error => {
$event.code = "";
$log.log('Wrong TOTP', error);
Expand Down Expand Up @@ -63,7 +67,8 @@ angular.module('core').controller('CoreLoginController', function($scope, $log,
return
}
$scope.success = true;
location.href = customization.plugins.core.loginredir || $scope.sanitizeNextPage() || '/';
nextPage = $scope.sanitizeNextPage();
location.href = customization.plugins.core.loginredir || nextPage;
}, error => {
$scope.working = false;
$log.log('Authentication failed', error);
Expand Down

0 comments on commit e3cc669

Please sign in to comment.