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.Mvc;
|
||||||
using System.Web.Routing;
|
using System.Web.Routing;
|
||||||
|
using WebsitePanel.WebDavPortal.UI.Routes;
|
||||||
|
|
||||||
namespace WebsitePanel.WebDavPortal
|
namespace WebsitePanel.WebDavPortal
|
||||||
{
|
{
|
||||||
|
@ -9,6 +10,18 @@ namespace WebsitePanel.WebDavPortal
|
||||||
{
|
{
|
||||||
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
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(
|
routes.MapRoute(
|
||||||
name: "Office365DocumentRoute",
|
name: "Office365DocumentRoute",
|
||||||
url: "office365/{org}/{*pathPart}",
|
url: "office365/{org}/{*pathPart}",
|
||||||
|
|
|
@ -32,4 +32,17 @@ textarea {
|
||||||
color: red;
|
color: red;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
padding-top: 5px;
|
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 System.Collections.Generic;
|
||||||
using WebsitePanel.Providers.OS;
|
using WebsitePanel.Providers.OS;
|
||||||
using WebDAV;
|
using WebDAV;
|
||||||
|
using WebsitePanel.WebDavPortal.UI.Routes;
|
||||||
|
|
||||||
namespace WebsitePanel.WebDavPortal.Controllers
|
namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
{
|
{
|
||||||
|
@ -50,7 +51,9 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
if (isAuthenticated)
|
if (isAuthenticated)
|
||||||
{
|
{
|
||||||
Session[WebDavAppConfigManager.Instance.SessionKeys.ItemId] = exchangeAccount.ItemId;
|
Session[WebDavAppConfigManager.Instance.SessionKeys.ItemId] = exchangeAccount.ItemId;
|
||||||
|
|
||||||
|
model.Groups = ES.Services.Organizations.GetSecurityGroupsByMember(exchangeAccount.ItemId, exchangeAccount.AccountId);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Session[WebDavAppConfigManager.Instance.SessionKeys.AccountInfo] = model;
|
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" });
|
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()
|
private void AutheticationToServicesUsingWebsitePanelUser()
|
||||||
{
|
{
|
||||||
var crypto = _kernel.Get<ICryptography>();
|
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
|
namespace WebsitePanel.WebDavPortal.Models
|
||||||
{
|
{
|
||||||
|
@ -21,6 +23,8 @@ namespace WebsitePanel.WebDavPortal.Models
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<ExchangeAccount> Groups { get; set; }
|
||||||
|
|
||||||
public string LdapError { get; set; }
|
public string LdapError { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -40,7 +40,7 @@ namespace WebsitePanel.WebDavPortal.Models
|
||||||
_itemId = itemId;
|
_itemId = itemId;
|
||||||
IKernel _kernel = new StandardKernel(new NinjectSettings { AllowNullInjection = true }, new WebDavExplorerAppModule());
|
IKernel _kernel = new StandardKernel(new NinjectSettings { AllowNullInjection = true }, new WebDavExplorerAppModule());
|
||||||
var accountModel = _kernel.Get<AccountModel>();
|
var accountModel = _kernel.Get<AccountModel>();
|
||||||
_rootFolders = ConnectToWebDavServer(accountModel.UserName);
|
_rootFolders = ConnectToWebDavServer(accountModel);
|
||||||
|
|
||||||
if (_rootFolders.Any())
|
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>();
|
var rootFolders = new List<SystemFile>();
|
||||||
foreach (var folder in ES.Services.EnterpriseStorage.GetEnterpriseFolders(_itemId))
|
foreach (var folder in ES.Services.EnterpriseStorage.GetEnterpriseFolders(_itemId))
|
||||||
{
|
{
|
||||||
var permissions = ES.Services.EnterpriseStorage.GetEnterpriseFolderPermissions(_itemId, folder.Name);
|
var permissions = ES.Services.EnterpriseStorage.GetEnterpriseFolderPermissions(_itemId, folder.Name);
|
||||||
if (permissions.Any(x => x.DisplayName == userName))
|
|
||||||
rootFolders.Add(folder);
|
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;
|
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.Config
|
||||||
@using WebsitePanel.WebDavPortal.DependencyInjection
|
@using WebsitePanel.WebDavPortal.DependencyInjection
|
||||||
@using WebsitePanel.WebDavPortal.Models
|
@using WebsitePanel.WebDavPortal.Models
|
||||||
|
@using WebsitePanel.WebDavPortal.UI.Routes;
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
@ -28,9 +29,10 @@
|
||||||
var account = kernel.Get<AccountModel>();
|
var account = kernel.Get<AccountModel>();
|
||||||
if (account != null)
|
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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -179,6 +179,7 @@
|
||||||
<Compile Include="Models\OfficeOnlineModel.cs" />
|
<Compile Include="Models\OfficeOnlineModel.cs" />
|
||||||
<Compile Include="Models\WebDavManager.cs" />
|
<Compile Include="Models\WebDavManager.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="UI\Routes\AccountRouteNames.cs" />
|
||||||
<Compile Include="WebConfigSections\ApplicationNameElement.cs" />
|
<Compile Include="WebConfigSections\ApplicationNameElement.cs" />
|
||||||
<Compile Include="WebConfigSections\ElementsRenderingElement.cs" />
|
<Compile Include="WebConfigSections\ElementsRenderingElement.cs" />
|
||||||
<Compile Include="WebConfigSections\FileIconsElement.cs" />
|
<Compile Include="WebConfigSections\FileIconsElement.cs" />
|
||||||
|
@ -289,6 +290,7 @@
|
||||||
<Content Include="App_GlobalResources\Resource.errors.resx">
|
<Content Include="App_GlobalResources\Resource.errors.resx">
|
||||||
<Generator>GlobalResourceProxyGenerator</Generator>
|
<Generator>GlobalResourceProxyGenerator</Generator>
|
||||||
<LastGenOutput>Resource.errors.designer.cs</LastGenOutput>
|
<LastGenOutput>Resource.errors.designer.cs</LastGenOutput>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue