webdav portal group permission fix
added logout button
This commit is contained in:
parent
2ec10f6988
commit
e4785dabca
8 changed files with 75 additions and 9 deletions
|
@ -1,5 +1,6 @@
|
|||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using WebsitePanel.WebDavPortal.UI.Routes;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal
|
||||
{
|
||||
|
@ -9,6 +10,18 @@ namespace WebsitePanel.WebDavPortal
|
|||
{
|
||||
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
||||
|
||||
routes.MapRoute(
|
||||
name: AccountRouteNames.Logout,
|
||||
url: "account/logout",
|
||||
defaults: new { controller = "Account", action = "Logout" }
|
||||
);
|
||||
|
||||
routes.MapRoute(
|
||||
name: AccountRouteNames.Login,
|
||||
url: "account/login",
|
||||
defaults: new { controller = "Account", action = "Login" }
|
||||
);
|
||||
|
||||
routes.MapRoute(
|
||||
name: "Office365DocumentRoute",
|
||||
url: "office365/{org}/{*pathPart}",
|
||||
|
|
|
@ -33,3 +33,16 @@ textarea {
|
|||
font-weight: bold;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
#username {
|
||||
display:inline-block;
|
||||
}
|
||||
|
||||
#logout {
|
||||
font-size: 1.2em;
|
||||
color: #9d9d9d;
|
||||
}
|
||||
|
||||
#logout :hover {
|
||||
color: white;
|
||||
}
|
|
@ -22,6 +22,7 @@ using WebsitePanel.WebDavPortal.Models;
|
|||
using System.Collections.Generic;
|
||||
using WebsitePanel.Providers.OS;
|
||||
using WebDAV;
|
||||
using WebsitePanel.WebDavPortal.UI.Routes;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Controllers
|
||||
{
|
||||
|
@ -51,6 +52,8 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
{
|
||||
Session[WebDavAppConfigManager.Instance.SessionKeys.ItemId] = exchangeAccount.ItemId;
|
||||
|
||||
model.Groups = ES.Services.Organizations.GetSecurityGroupsByMember(exchangeAccount.ItemId, exchangeAccount.AccountId);
|
||||
|
||||
try
|
||||
{
|
||||
Session[WebDavAppConfigManager.Instance.SessionKeys.AccountInfo] = model;
|
||||
|
@ -65,6 +68,14 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
return View(new AccountModel { LdapError = "The user name or password is incorrect" });
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ActionResult Logout()
|
||||
{
|
||||
Session[WebDavAppConfigManager.Instance.SessionKeys.AccountInfo] = null;
|
||||
|
||||
return RedirectToRoute(AccountRouteNames.Login);
|
||||
}
|
||||
|
||||
private void AutheticationToServicesUsingWebsitePanelUser()
|
||||
{
|
||||
var crypto = _kernel.Get<ICryptography>();
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using WebsitePanel.Providers.HostedSolution;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Models
|
||||
{
|
||||
|
@ -21,6 +23,8 @@ namespace WebsitePanel.WebDavPortal.Models
|
|||
}
|
||||
}
|
||||
|
||||
public IEnumerable<ExchangeAccount> Groups { get; set; }
|
||||
|
||||
public string LdapError { get; set; }
|
||||
}
|
||||
}
|
|
@ -40,7 +40,7 @@ namespace WebsitePanel.WebDavPortal.Models
|
|||
_itemId = itemId;
|
||||
IKernel _kernel = new StandardKernel(new NinjectSettings { AllowNullInjection = true }, new WebDavExplorerAppModule());
|
||||
var accountModel = _kernel.Get<AccountModel>();
|
||||
_rootFolders = ConnectToWebDavServer(accountModel.UserName);
|
||||
_rootFolders = ConnectToWebDavServer(accountModel);
|
||||
|
||||
if (_rootFolders.Any())
|
||||
{
|
||||
|
@ -126,14 +126,22 @@ namespace WebsitePanel.WebDavPortal.Models
|
|||
}
|
||||
}
|
||||
|
||||
private IList<SystemFile> ConnectToWebDavServer(string userName)
|
||||
private IList<SystemFile> ConnectToWebDavServer(AccountModel user)
|
||||
{
|
||||
var rootFolders = new List<SystemFile>();
|
||||
foreach (var folder in ES.Services.EnterpriseStorage.GetEnterpriseFolders(_itemId))
|
||||
{
|
||||
var permissions = ES.Services.EnterpriseStorage.GetEnterpriseFolderPermissions(_itemId, folder.Name);
|
||||
if (permissions.Any(x => x.DisplayName == userName))
|
||||
|
||||
foreach (var permission in permissions)
|
||||
{
|
||||
if ((!permission.IsGroup && permission.DisplayName == user.UserName)
|
||||
|| (permission.IsGroup && user.Groups.Any(x=> x.DisplayName == permission.DisplayName)))
|
||||
{
|
||||
rootFolders.Add(folder);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rootFolders;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.UI.Routes
|
||||
{
|
||||
public class AccountRouteNames
|
||||
{
|
||||
public const string Logout = "AccountLogout";
|
||||
public const string Login = "AccountLogin";
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
@using WebsitePanel.WebDavPortal.Config
|
||||
@using WebsitePanel.WebDavPortal.DependencyInjection
|
||||
@using WebsitePanel.WebDavPortal.Models
|
||||
@using WebsitePanel.WebDavPortal.UI.Routes;
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -28,7 +29,8 @@
|
|||
var account = kernel.Get<AccountModel>();
|
||||
if (account != null)
|
||||
{
|
||||
<h4 class="nav navbar-text navbar-right">@account.UserName</h4>
|
||||
<a id="logout" class="nav navbar-text navbar-right" href="@Url.RouteUrl(AccountRouteNames.Logout)" title="Log out"><i class="glyphicon glyphicon-log-out"></i></a>
|
||||
<h4 id="username" class="nav navbar-text navbar-right">@account.UserName</h4>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
|
|
@ -179,6 +179,7 @@
|
|||
<Compile Include="Models\OfficeOnlineModel.cs" />
|
||||
<Compile Include="Models\WebDavManager.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UI\Routes\AccountRouteNames.cs" />
|
||||
<Compile Include="WebConfigSections\ApplicationNameElement.cs" />
|
||||
<Compile Include="WebConfigSections\ElementsRenderingElement.cs" />
|
||||
<Compile Include="WebConfigSections\FileIconsElement.cs" />
|
||||
|
@ -289,6 +290,7 @@
|
|||
<Content Include="App_GlobalResources\Resource.errors.resx">
|
||||
<Generator>GlobalResourceProxyGenerator</Generator>
|
||||
<LastGenOutput>Resource.errors.designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue