diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/App_Start/RouteConfig.cs b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/App_Start/RouteConfig.cs index c7b92062..3316d657 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/App_Start/RouteConfig.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/App_Start/RouteConfig.cs @@ -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}", diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Site.css b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Site.css index 20e5c6b1..2389aea4 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Site.css +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Site.css @@ -32,4 +32,17 @@ textarea { color: red; font-weight: bold; padding-top: 5px; - } \ No newline at end of file + } + +#username { + display:inline-block; +} + +#logout { + font-size: 1.2em; + color: #9d9d9d; +} + +#logout :hover { + color: white; +} \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/AccountController.cs b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/AccountController.cs index 242cd617..b95f91d6 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/AccountController.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/AccountController.cs @@ -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 { @@ -50,7 +51,9 @@ namespace WebsitePanel.WebDavPortal.Controllers if (isAuthenticated) { 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(); diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Models/AccountModel.cs b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Models/AccountModel.cs index 72956e73..2ad1e6a8 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Models/AccountModel.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Models/AccountModel.cs @@ -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 Groups { get; set; } + public string LdapError { get; set; } } } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Models/WebDavManager.cs b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Models/WebDavManager.cs index 05f578d8..319a54bb 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Models/WebDavManager.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Models/WebDavManager.cs @@ -40,7 +40,7 @@ namespace WebsitePanel.WebDavPortal.Models _itemId = itemId; IKernel _kernel = new StandardKernel(new NinjectSettings { AllowNullInjection = true }, new WebDavExplorerAppModule()); var accountModel = _kernel.Get(); - _rootFolders = ConnectToWebDavServer(accountModel.UserName); + _rootFolders = ConnectToWebDavServer(accountModel); if (_rootFolders.Any()) { @@ -126,14 +126,22 @@ namespace WebsitePanel.WebDavPortal.Models } } - private IList ConnectToWebDavServer(string userName) + private IList ConnectToWebDavServer(AccountModel user) { var rootFolders = new List(); 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)) - 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; } diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/UI/Routes/AccountRouteNames.cs b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/UI/Routes/AccountRouteNames.cs new file mode 100644 index 00000000..035fde95 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/UI/Routes/AccountRouteNames.cs @@ -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"; + } +} \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/Shared/_Layout.cshtml b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/Shared/_Layout.cshtml index 6162ed3a..a03b50f7 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/Shared/_Layout.cshtml +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/Shared/_Layout.cshtml @@ -2,6 +2,7 @@ @using WebsitePanel.WebDavPortal.Config @using WebsitePanel.WebDavPortal.DependencyInjection @using WebsitePanel.WebDavPortal.Models +@using WebsitePanel.WebDavPortal.UI.Routes; @@ -28,9 +29,10 @@ var account = kernel.Get(); if (account != null) { - + + } - } +} diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/WebsitePanel.WebDavPortal.csproj b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/WebsitePanel.WebDavPortal.csproj index 5b2ea9ec..f49ff0d3 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/WebsitePanel.WebDavPortal.csproj +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/WebsitePanel.WebDavPortal.csproj @@ -179,6 +179,7 @@ + @@ -289,6 +290,7 @@ GlobalResourceProxyGenerator Resource.errors.designer.cs + Designer