mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-11-28 17:32:44 +08:00
Further work updating security model
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4045826
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Roles.Models.NoRecord;
|
||||
using Orchard.Security;
|
||||
|
||||
namespace Orchard.Roles.Models {
|
||||
public static class UserSimulation {
|
||||
public static IUser Create(string role) {
|
||||
var simulation = new ContentItemBuilder("user")
|
||||
.Weld<SimulatedUser>()
|
||||
.Weld<SimulatedUserRoles>()
|
||||
.Build();
|
||||
simulation.As<SimulatedUserRoles>().Roles = new[] {role};
|
||||
return simulation.As<IUser>();
|
||||
}
|
||||
|
||||
class SimulatedUser : ContentPart, IUser {
|
||||
public int Id { get { return ContentItem.Id; } }
|
||||
public string UserName { get { return null; } }
|
||||
public string Email { get { return null; } }
|
||||
}
|
||||
|
||||
class SimulatedUserRoles : ContentPart, IUserRoles {
|
||||
public IList<string> Roles { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
9
src/Orchard/Security/UnauthorizedException.cs
Normal file
9
src/Orchard/Security/UnauthorizedException.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Orchard.Security {
|
||||
public class UnauthorizedException : ApplicationException {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user