Permission-based authorization utilizing Policies
This commit is contained in:
		| @ -3,6 +3,7 @@ | ||||
| @using Oqtane.Models | ||||
| @using Oqtane.Themes | ||||
| @using Oqtane.Shared | ||||
| @using Oqtane.Security | ||||
| @inherits ThemeObjectBase | ||||
| @inject IUriHelper UriHelper | ||||
| @inject IUserService UserService | ||||
| @ -44,7 +45,7 @@ | ||||
|                 <label for="Pane" class="control-label" style="color: white !important;">Pane: </label> | ||||
|                 <select class="form-control" @bind="@pane"> | ||||
|                     <option value=""><Select Pane></option> | ||||
|                     @foreach (string pane in PageState.Page.Panes.Split(';')) | ||||
|                     @foreach (string pane in PageState.Page.Panes.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) | ||||
|                     { | ||||
|                         <option value="@pane">@pane Pane</option> | ||||
|                     } | ||||
| @ -89,7 +90,7 @@ | ||||
|         { | ||||
|             pagemanagementmoduleid = modules.FirstOrDefault().ModuleId; | ||||
|         } | ||||
|         if (UserService.IsAuthorized(PageState.User, PageState.Page.EditPermissions)) | ||||
|         if (UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions)) | ||||
|         { | ||||
|             display = "display: inline"; | ||||
|         } | ||||
| @ -100,8 +101,7 @@ | ||||
|         Module module = new Module(); | ||||
|         module.SiteId = PageState.Site.SiteId; | ||||
|         module.ModuleDefinitionName = moduledefinitionname; | ||||
|         module.ViewPermissions = PageState.Page.ViewPermissions; | ||||
|         module.EditPermissions = PageState.Page.EditPermissions; | ||||
|         module.Permissions = PageState.Page.Permissions; | ||||
|         await ModuleService.AddModuleAsync(module); | ||||
|  | ||||
|         List<Module> modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId, moduledefinitionname); | ||||
|  | ||||
| @ -2,6 +2,7 @@ | ||||
| @using Oqtane.Themes | ||||
| @using Oqtane.Services | ||||
| @using Oqtane.Models; | ||||
| @using Oqtane.Security | ||||
| @inherits ThemeObjectBase | ||||
| @inject IPageService PageService | ||||
| @inject IUserService UserService | ||||
| @ -18,7 +19,7 @@ | ||||
|     } | ||||
|     @foreach (var p in pages) | ||||
|     { | ||||
|         if (p.IsNavigation && UserService.IsAuthorized(PageState.User, p.ViewPermissions)) | ||||
|         if (p.IsNavigation && UserSecurity.IsAuthorized(PageState.User, "View", p.Permissions)) | ||||
|         { | ||||
|             string url = NavigateUrl(p.Path); | ||||
|             <li class="nav-item px-3"> | ||||
|  | ||||
| @ -2,6 +2,7 @@ | ||||
| @using Oqtane.Services | ||||
| @using Oqtane.Models | ||||
| @using Oqtane.Shared | ||||
| @using Oqtane.Security | ||||
| @inherits ContainerBase | ||||
| @inject IUriHelper UriHelper | ||||
| @inject IUserService UserService | ||||
| @ -32,7 +33,7 @@ | ||||
|         { | ||||
|             actions.Add(new ActionViewModel { Action = "down", Name = "Move Down" }); | ||||
|         } | ||||
|         foreach (string pane in PageState.Page.Panes.Split(';')) | ||||
|         foreach (string pane in PageState.Page.Panes.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) | ||||
|         { | ||||
|             if (pane != ModuleState.Pane) | ||||
|             { | ||||
| @ -42,7 +43,7 @@ | ||||
|         actions.Add(new ActionViewModel { Action = "settings", Name = "Settings" }); | ||||
|         actions.Add(new ActionViewModel { Action = "delete", Name = "Delete" }); | ||||
|  | ||||
|         if (UserService.IsAuthorized(PageState.User, ModuleState.EditPermissions)) | ||||
|         if (UserSecurity.IsAuthorized(PageState.User, "Edit", ModuleState.Permissions)) | ||||
|         { | ||||
|             display = "display: inline"; | ||||
|         } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Shaun Walker
					Shaun Walker