case insensitive section comparison

This commit is contained in:
Mario Lopez
2019-05-29 11:39:10 +10:00
parent c4ba0454fc
commit 1ad4414026
2 changed files with 7 additions and 3 deletions

View File

@@ -39,10 +39,14 @@ app.config(function ($routeProvider) {
$route.current.params.section = "content";
}
var found = _.find(user.allowedSections, function (s) {
return s.localeCompare($route.current.params.section, undefined, { sensitivity: 'accent' }) === 0;
})
// U4-5430, Benjamin Howarth
// We need to change the current route params if the user only has access to a single section
// To do this we need to grab the current user's allowed sections, then reject the promise with the correct path.
if (user.allowedSections.indexOf($route.current.params.section) > -1) {
if (found) {
//this will resolve successfully so the route will continue
return $q.when(true);
} else {
@@ -119,7 +123,7 @@ app.config(function ($routeProvider) {
sectionService.getSectionsForUser().then(function(sections) {
//find the one we're requesting
var found = _.find(sections, function(s) {
return s.alias === $routeParams.section;
return s.alias.localeCompare($routeParams.section, undefined, { sensitivity: 'accent' }) === 0;
})
if (found && found.routePath) {
//there's a custom route path so redirect

View File

@@ -39,6 +39,6 @@ namespace Umbraco.Web.Services
/// <inheritdoc />
public ISection GetByAlias(string appAlias)
=> GetSections().FirstOrDefault(t => t.Alias == appAlias);
=> GetSections().FirstOrDefault(t => t.Alias.Equals(appAlias, StringComparison.OrdinalIgnoreCase));
}
}