Minor style changes
This commit is contained in:
@@ -141,7 +141,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
/// <returns>
|
||||
/// The <see cref="DictionaryDisplay"/>. Returns a not found response when dictionary item does not exist
|
||||
/// </returns>
|
||||
public ActionResult<DictionaryDisplay> GetById(int id)
|
||||
public ActionResult<DictionaryDisplay> GetById(int id)
|
||||
{
|
||||
var dictionary = _localizationService.GetDictionaryItemById(id);
|
||||
if (dictionary == null)
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
return candidate;
|
||||
}
|
||||
|
||||
//if it's a post we can try to read from the body and bind from the json value
|
||||
// if it's a post we can try to read from the body and bind from the json value
|
||||
if (context.RouteContext.HttpContext.Request.Method == HttpMethod.Post.ToString())
|
||||
{
|
||||
// We need to use the asynchronous method here if synchronous IO is not allowed (it may or may not be, depending
|
||||
@@ -88,11 +88,11 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
}
|
||||
catch (JsonReaderException)
|
||||
{
|
||||
//can't convert
|
||||
// can't convert
|
||||
}
|
||||
catch (JsonSerializationException)
|
||||
{
|
||||
//can't convert
|
||||
// can't convert
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,22 +112,21 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
|
||||
if (requestParam == string.Empty && _supportedTypes.Length > 0)
|
||||
{
|
||||
//if it's empty then in theory we can select any of the actions since they'll all need to deal with empty or null parameters
|
||||
//so we'll try to use the first one available
|
||||
// if it's empty then in theory we can select any of the actions since they'll all need to deal with empty or null parameters
|
||||
// so we'll try to use the first one available
|
||||
foundCandidate = MatchByType(_supportedTypes[0], context);
|
||||
if (foundCandidate.HasValue)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (requestParam != null)
|
||||
{
|
||||
foreach (var paramType in _supportedTypes)
|
||||
{
|
||||
//check if this is IEnumerable and if so this will get it's type
|
||||
//we need to know this since the requestParam will always just be a string
|
||||
// check if this is IEnumerable and if so this will get it's type
|
||||
// we need to know this since the requestParam will always just be a string
|
||||
var enumType = paramType.GetEnumeratedType();
|
||||
|
||||
var converted = requestParam.TryConvertTo(enumType ?? paramType);
|
||||
@@ -150,11 +149,12 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
if (context.Candidates.Count() > 1)
|
||||
{
|
||||
//choose the one that has the parameter with the T type
|
||||
// choose the one that has the parameter with the T type
|
||||
var candidate = context.Candidates.FirstOrDefault(x => x.Action.Parameters.FirstOrDefault(p => p.Name == _parameterName && p.ParameterType == idType) != null);
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,63 +101,63 @@ namespace Umbraco.Web.BackOffice.Filters
|
||||
{
|
||||
using (var scope = _scopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
if (actionContext?.HttpContext.Request == null || actionContext.HttpContext.User?.Identity == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// don't execute if it's already been done
|
||||
if (!(_requestCache.Get(nameof(CheckIfUserTicketDataIsStaleFilter)) is null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var identity = actionContext.HttpContext.User.Identity as UmbracoBackOfficeIdentity;
|
||||
if (identity == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Attempt<int> userId = identity.Id.TryConvertTo<int>();
|
||||
if (userId == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IUser user = _userService.GetUserById(userId.Result);
|
||||
if (user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// a list of checks to execute, if any of them pass then we resync
|
||||
var checks = new Func<bool>[]
|
||||
{
|
||||
() => user.Username != identity.Username,
|
||||
() =>
|
||||
if (actionContext?.HttpContext.Request == null || actionContext.HttpContext.User?.Identity == null)
|
||||
{
|
||||
CultureInfo culture = user.GetUserCulture(_localizedTextService, _globalSettings.Value);
|
||||
return culture != null && culture.ToString() != identity.Culture;
|
||||
},
|
||||
() => user.AllowedSections.UnsortedSequenceEqual(identity.AllowedApplications) == false,
|
||||
() => user.Groups.Select(x => x.Alias).UnsortedSequenceEqual(identity.Roles) == false,
|
||||
() =>
|
||||
{
|
||||
var startContentIds = user.CalculateContentStartNodeIds(_entityService);
|
||||
return startContentIds.UnsortedSequenceEqual(identity.StartContentNodes) == false;
|
||||
},
|
||||
() =>
|
||||
{
|
||||
var startMediaIds = user.CalculateMediaStartNodeIds(_entityService);
|
||||
return startMediaIds.UnsortedSequenceEqual(identity.StartMediaNodes) == false;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
if (checks.Any(check => check()))
|
||||
{
|
||||
await ReSync(user, actionContext);
|
||||
// don't execute if it's already been done
|
||||
if (!(_requestCache.Get(nameof(CheckIfUserTicketDataIsStaleFilter)) is null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var identity = actionContext.HttpContext.User.Identity as UmbracoBackOfficeIdentity;
|
||||
if (identity == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Attempt<int> userId = identity.Id.TryConvertTo<int>();
|
||||
if (userId == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IUser user = _userService.GetUserById(userId.Result);
|
||||
if (user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// a list of checks to execute, if any of them pass then we resync
|
||||
var checks = new Func<bool>[]
|
||||
{
|
||||
() => user.Username != identity.Username,
|
||||
() =>
|
||||
{
|
||||
CultureInfo culture = user.GetUserCulture(_localizedTextService, _globalSettings.Value);
|
||||
return culture != null && culture.ToString() != identity.Culture;
|
||||
},
|
||||
() => user.AllowedSections.UnsortedSequenceEqual(identity.AllowedApplications) == false,
|
||||
() => user.Groups.Select(x => x.Alias).UnsortedSequenceEqual(identity.Roles) == false,
|
||||
() =>
|
||||
{
|
||||
var startContentIds = user.CalculateContentStartNodeIds(_entityService);
|
||||
return startContentIds.UnsortedSequenceEqual(identity.StartContentNodes) == false;
|
||||
},
|
||||
() =>
|
||||
{
|
||||
var startMediaIds = user.CalculateMediaStartNodeIds(_entityService);
|
||||
return startMediaIds.UnsortedSequenceEqual(identity.StartMediaNodes) == false;
|
||||
}
|
||||
};
|
||||
|
||||
if (checks.Any(check => check()))
|
||||
{
|
||||
await ReSync(user, actionContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -86,6 +86,7 @@ namespace Umbraco.Extensions
|
||||
{
|
||||
request.Body.Seek(0, SeekOrigin.Begin);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user