removes obsolete method
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using AuthorizeAttribute = System.Web.Mvc.AuthorizeAttribute;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Security;
|
||||
using Umbraco.Core.Composing;
|
||||
using Current = Umbraco.Web.Composing.Current;
|
||||
|
||||
namespace Umbraco.Web.Mvc
|
||||
{
|
||||
@@ -14,35 +15,6 @@ namespace Umbraco.Web.Mvc
|
||||
/// </summary>
|
||||
public sealed class MemberAuthorizeAttribute : AuthorizeAttribute
|
||||
{
|
||||
// see note in HttpInstallAuthorizeAttribute
|
||||
private readonly UmbracoContext _umbracoContext;
|
||||
|
||||
private UmbracoContext UmbracoContext => _umbracoContext ?? Current.UmbracoContext;
|
||||
|
||||
/// <summary>
|
||||
/// THIS SHOULD BE ONLY USED FOR UNIT TESTS
|
||||
/// </summary>
|
||||
/// <param name="umbracoContext"></param>
|
||||
public MemberAuthorizeAttribute(UmbracoContext umbracoContext)
|
||||
{
|
||||
if (umbracoContext == null) throw new ArgumentNullException("umbracoContext");
|
||||
_umbracoContext = umbracoContext;
|
||||
}
|
||||
|
||||
public MemberAuthorizeAttribute()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flag for whether to allow all site visitors or just authenticated members
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is the same as applying the [AllowAnonymous] attribute
|
||||
/// </remarks>
|
||||
[Obsolete("Use [AllowAnonymous] instead")]
|
||||
public bool AllowAll { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Comma delimited list of allowed member types
|
||||
/// </summary>
|
||||
@@ -70,17 +42,15 @@ namespace Umbraco.Web.Mvc
|
||||
var members = new List<int>();
|
||||
foreach (var s in AllowMembers.Split(','))
|
||||
{
|
||||
int id;
|
||||
if (int.TryParse(s, out id))
|
||||
if (int.TryParse(s, out var id))
|
||||
{
|
||||
members.Add(id);
|
||||
}
|
||||
}
|
||||
|
||||
return UmbracoContext.Security.IsMemberAuthorized(AllowAll,
|
||||
AllowType.Split(','),
|
||||
AllowGroup.Split(','),
|
||||
members);
|
||||
var helper = Current.Factory.GetInstance<MembershipHelper>();
|
||||
return helper.IsMemberAuthorized(AllowType.Split(','), AllowGroup.Split(','), members);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -599,20 +599,15 @@ namespace Umbraco.Web.Security
|
||||
/// <summary>
|
||||
/// Returns true or false if the currently logged in member is authorized based on the parameters provided
|
||||
/// </summary>
|
||||
/// <param name="allowAll"></param>
|
||||
/// <param name="allowTypes"></param>
|
||||
/// <param name="allowGroups"></param>
|
||||
/// <param name="allowMembers"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool IsMemberAuthorized(
|
||||
bool allowAll = false,
|
||||
IEnumerable<string> allowTypes = null,
|
||||
IEnumerable<string> allowGroups = null,
|
||||
IEnumerable<int> allowMembers = null)
|
||||
{
|
||||
if (allowAll)
|
||||
return true;
|
||||
|
||||
if (allowTypes == null)
|
||||
allowTypes = Enumerable.Empty<string>();
|
||||
if (allowGroups == null)
|
||||
|
||||
@@ -33,30 +33,7 @@ namespace Umbraco.Web.Security
|
||||
_userService = userService;
|
||||
_globalSettings = globalSettings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true or false if the currently logged in member is authorized based on the parameters provided
|
||||
/// </summary>
|
||||
/// <param name="allowAll"></param>
|
||||
/// <param name="allowTypes"></param>
|
||||
/// <param name="allowGroups"></param>
|
||||
/// <param name="allowMembers"></param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("Use MembershipHelper.IsMemberAuthorized instead")]
|
||||
public bool IsMemberAuthorized(
|
||||
bool allowAll = false,
|
||||
IEnumerable<string> allowTypes = null,
|
||||
IEnumerable<string> allowGroups = null,
|
||||
IEnumerable<int> allowMembers = null)
|
||||
{
|
||||
if (Current.UmbracoContext == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var helper = Current.Factory.GetInstance<MembershipHelper>();
|
||||
return helper.IsMemberAuthorized(allowAll, allowTypes, allowGroups, allowMembers);
|
||||
}
|
||||
|
||||
|
||||
private IUser _currentUser;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Http;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Security;
|
||||
using Umbraco.Core.Composing;
|
||||
using Current = Umbraco.Web.Composing.Current;
|
||||
|
||||
namespace Umbraco.Web.WebApi
|
||||
{
|
||||
@@ -11,37 +13,6 @@ namespace Umbraco.Web.WebApi
|
||||
/// </summary>
|
||||
public sealed class MemberAuthorizeAttribute : AuthorizeAttribute
|
||||
{
|
||||
private readonly UmbracoContext _umbracoContext;
|
||||
|
||||
private UmbracoContext GetUmbracoContext()
|
||||
{
|
||||
return _umbracoContext ?? UmbracoContext.Current;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// THIS SHOULD BE ONLY USED FOR UNIT TESTS
|
||||
/// </summary>
|
||||
/// <param name="umbracoContext"></param>
|
||||
public MemberAuthorizeAttribute(UmbracoContext umbracoContext)
|
||||
{
|
||||
if (umbracoContext == null) throw new ArgumentNullException("umbracoContext");
|
||||
_umbracoContext = umbracoContext;
|
||||
}
|
||||
|
||||
public MemberAuthorizeAttribute()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flag for whether to allow all site visitors or just authenticated members
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is the same as applying the [AllowAnonymous] attribute
|
||||
/// </remarks>
|
||||
[Obsolete("Use [AllowAnonymous] instead")]
|
||||
public bool AllowAll { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Comma delimited list of allowed member types
|
||||
/// </summary>
|
||||
@@ -69,17 +40,14 @@ namespace Umbraco.Web.WebApi
|
||||
var members = new List<int>();
|
||||
foreach (var s in AllowMembers.Split(','))
|
||||
{
|
||||
int id;
|
||||
if (int.TryParse(s, out id))
|
||||
if (int.TryParse(s, out var id))
|
||||
{
|
||||
members.Add(id);
|
||||
}
|
||||
}
|
||||
|
||||
return GetUmbracoContext().Security.IsMemberAuthorized(AllowAll,
|
||||
AllowType.Split(','),
|
||||
AllowGroup.Split(','),
|
||||
members);
|
||||
var helper = Current.Factory.GetInstance<MembershipHelper>();
|
||||
return helper.IsMemberAuthorized(AllowType.Split(','), AllowGroup.Split(','), members);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user