From 83e991b4b4706ac123b43624a32dc59c994190ab Mon Sep 17 00:00:00 2001 From: Ernst Peter Tamminga Date: Fri, 2 Aug 2019 08:42:49 +0200 Subject: [PATCH] Close #52 --- Controllers/IdentitySwitcherController.cs | 44 +++++++++---------- IdentitySwitcher.csproj | 4 +- Installation/CleanUp/Cleanup.03.01.00.txt | 1 + Installation/IdentitySwitcher.dnn | 5 ++- Installation/License.txt | 2 +- .../ReleaseNotes/Release.03.01.00.txt | 16 +++++++ Properties/AssemblyInfo.cs | 4 +- Settings.ascx.cs | 36 +++++++-------- ViewIdentitySwitcher.ascx.cs | 34 +++++++------- 9 files changed, 83 insertions(+), 63 deletions(-) create mode 100644 Installation/CleanUp/Cleanup.03.01.00.txt create mode 100644 Installation/ReleaseNotes/Release.03.01.00.txt diff --git a/Controllers/IdentitySwitcherController.cs b/Controllers/IdentitySwitcherController.cs index 42e480e..451ed57 100644 --- a/Controllers/IdentitySwitcherController.cs +++ b/Controllers/IdentitySwitcherController.cs @@ -62,7 +62,7 @@ public IHttpActionResult GetSearchItems() var resultData = new List(); var profileProperties = - ProfileController.GetPropertyDefinitionsByPortal(this.PortalSettings.PortalId, false); + ProfileController.GetPropertyDefinitionsByPortal(PortalSettings.PortalId, false); foreach (ProfilePropertyDefinition definition in profileProperties) { @@ -70,13 +70,13 @@ public IHttpActionResult GetSearchItems() } resultData.AddRange(new List { "RoleName", "Email", "Username" }); - result = this.Ok(resultData); + result = Ok(resultData); } catch (Exception exception) { Exceptions.LogException(exception); - result = this.InternalServerError(exception); + result = InternalServerError(exception); } return result; @@ -105,14 +105,14 @@ public IHttpActionResult GetUsers(string searchText = null, string selectedSearc { // ..get all users if no searchtext is provided or filtered users if a searchtext is provided. usersInfo = searchText == null - ? this.GetAllUsers() - : this.GetFilteredUsers(searchText, selectedSearchItem); - usersInfo = this.SortUsers(usersInfo); + ? GetAllUsers() + : GetFilteredUsers(searchText, selectedSearchItem); + usersInfo = SortUsers(usersInfo); } - this.AddDefaultUsers(usersInfo); + AddDefaultUsers(usersInfo); - var selectedUserId = this.UserInfo.UserID; + var selectedUserId = UserInfo.UserID; var resultData = new UserCollectionDto { @@ -128,13 +128,13 @@ public IHttpActionResult GetUsers(string searchText = null, string selectedSearc SelectedUserId = selectedUserId }; - result = this.Ok(resultData); + result = Ok(resultData); } catch (Exception exception) { Exceptions.LogException(exception); - result = this.InternalServerError(exception); + result = InternalServerError(exception); } return result; @@ -160,25 +160,25 @@ public IHttpActionResult SwitchUser(int selectedUserId, string selectedUserName) } else { - var selectedUser = UserController.GetUserById(this.PortalSettings.PortalId, selectedUserId); + var selectedUser = UserController.GetUserById(PortalSettings.PortalId, selectedUserId); - DataCache.ClearUserCache(this.PortalSettings.PortalId, selectedUserName); + DataCache.ClearUserCache(PortalSettings.PortalId, selectedUserName); // Sign current user out. var objPortalSecurity = new PortalSecurity(); objPortalSecurity.SignOut(); // Sign new user in. - UserController.UserLogin(this.PortalSettings.PortalId, selectedUser, this.PortalSettings.PortalName, + UserController.UserLogin(PortalSettings.PortalId, selectedUser, PortalSettings.PortalName, HttpContext.Current.Request.UserHostAddress, false); } - result = this.Ok(); + result = Ok(); } catch (Exception exception) { Exceptions.LogException(exception); - result = this.InternalServerError(exception); + result = InternalServerError(exception); } return result; @@ -192,7 +192,7 @@ public IHttpActionResult SwitchUser(int selectedUserId, string selectedUserName) /// private List GetAllUsers() { - var users = UserController.GetUsers(this.PortalSettings.PortalId).OfType().ToList(); + var users = UserController.GetUsers(PortalSettings.PortalId).OfType().ToList(); return users; } @@ -203,7 +203,7 @@ private List GetAllUsers() private void AddDefaultUsers(List users) { var repository = new IdentitySwitcherModuleSettingsRepository(); - var settings = repository.GetSettings(this.ActiveModule); + var settings = repository.GetSettings(ActiveModule); // If includehost setting is set to true, add host users to the list. if (settings.IncludeHost ?? false) @@ -228,7 +228,7 @@ private void AddDefaultUsers(List users) private List SortUsers(List users) { var repository = new IdentitySwitcherModuleSettingsRepository(); - var settings = repository.GetSettings(this.ActiveModule); + var settings = repository.GetSettings(ActiveModule); switch (settings.SortBy) { @@ -260,22 +260,22 @@ private List GetFilteredUsers(string searchText, string selectedSearch { case "Email": users = UserController - .GetUsersByEmail(this.PortalSettings.PortalId, searchText + "%", -1, -1, ref total) + .GetUsersByEmail(PortalSettings.PortalId, searchText + "%", -1, -1, ref total) .OfType().ToList(); break; case "Username": users = UserController - .GetUsersByUserName(this.PortalSettings.PortalId, searchText + "%", -1, -1, ref total) + .GetUsersByUserName(PortalSettings.PortalId, searchText + "%", -1, -1, ref total) .OfType().ToList(); break; case "RoleName": users = RoleController - .Instance.GetUsersByRole(this.PortalSettings.PortalId, searchText).ToList(); + .Instance.GetUsersByRole(PortalSettings.PortalId, searchText).ToList(); break; default: users = UserController - .GetUsersByProfileProperty(this.PortalSettings.PortalId, selectedSearchItem, searchText + "%", + .GetUsersByProfileProperty(PortalSettings.PortalId, selectedSearchItem, searchText + "%", 0, 1000, ref total) .OfType().ToList(); break; diff --git a/IdentitySwitcher.csproj b/IdentitySwitcher.csproj index 3230b85..05775dc 100644 --- a/IdentitySwitcher.csproj +++ b/IdentitySwitcher.csproj @@ -137,7 +137,9 @@ Designer + + Designer @@ -200,7 +202,7 @@ - + diff --git a/Installation/CleanUp/Cleanup.03.01.00.txt b/Installation/CleanUp/Cleanup.03.01.00.txt new file mode 100644 index 0000000..2ac820c --- /dev/null +++ b/Installation/CleanUp/Cleanup.03.01.00.txt @@ -0,0 +1 @@ +Install\Module\IdentitySwitcher.03.00.00.Install.zip \ No newline at end of file diff --git a/Installation/IdentitySwitcher.dnn b/Installation/IdentitySwitcher.dnn index 03d2b43..67d34b5 100644 --- a/Installation/IdentitySwitcher.dnn +++ b/Installation/IdentitySwitcher.dnn @@ -1,6 +1,6 @@ - + IdentitySwitcher The IdentitySwitcher is a simple and useful tool to allow you to switch between users, without knowing their passwords. DesktopModules\IdentitySwitcher\IdentitySwitcher.png @@ -11,7 +11,7 @@ info@dnn-connect.org - + true @@ -78,6 +78,7 @@ + diff --git a/Installation/License.txt b/Installation/License.txt index 0d588f0..0dd1248 100644 --- a/Installation/License.txt +++ b/Installation/License.txt @@ -1,5 +1,5 @@ DNN-Connect - https://www.dnn-connect.org
-Copyright (c) 2018
+Copyright (c) 2019
by DNN-Connect
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated diff --git a/Installation/ReleaseNotes/Release.03.01.00.txt b/Installation/ReleaseNotes/Release.03.01.00.txt new file mode 100644 index 0000000..989b2ee --- /dev/null +++ b/Installation/ReleaseNotes/Release.03.01.00.txt @@ -0,0 +1,16 @@ +

Release notes Identity Switcher 03.01.00

+

Full details on the changes can be found in great detail at https://github.com/DNN-Connect/IdentitySwitcher.

+

BUG FIXES

+
    +
  • Corrected handling of users in multiple portals within 1 DNN installation
  • +
+

CHANGES

+
    +
  • Code clean-up
  • +
  • Improved UI with new Angular front end construction
  • +
+

NOTES

+
    +
  • Tested on DNN 9.3.2 and when placing the module on a page you need to refresh the page at least once to display the module correctly
  • +
  • Don't place multiple IdentitySwitcher modules on the same page as the module is not fit for such a scenario
  • +
\ No newline at end of file diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index b959d4b..8a99a0a 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("3.0.0.0")] -[assembly: AssemblyFileVersion("3.0.0.0")] \ No newline at end of file +[assembly: AssemblyVersion("3.1.0.0")] +[assembly: AssemblyFileVersion("3.1.0.0")] \ No newline at end of file diff --git a/Settings.ascx.cs b/Settings.ascx.cs index 019ef6c..8c7587d 100644 --- a/Settings.ascx.cs +++ b/Settings.ascx.cs @@ -61,31 +61,31 @@ public override void LoadSettings() { try { - if (this.Page.IsPostBack == false) + if (Page.IsPostBack == false) { var repository = new IdentitySwitcherModuleSettingsRepository(); - var settings = repository.GetSettings(this.ModuleConfiguration); + var settings = repository.GetSettings(ModuleConfiguration); - this.rbSortBy.Items.Add(new ListItem(Localization.GetString("SortByDisplayName.Text", this.LocalResourceFile), "0")); - this.rbSortBy.Items.Add(new ListItem(Localization.GetString("SortByUserName.Text", this.LocalResourceFile), "1")); + rbSortBy.Items.Add(new ListItem(Localization.GetString("SortByDisplayName.Text", LocalResourceFile), "0")); + rbSortBy.Items.Add(new ListItem(Localization.GetString("SortByUserName.Text", LocalResourceFile), "1")); - this.rbSelectingMethod.Items.Add(new ListItem(Localization.GetString("Fast.Text", this.LocalResourceFile), "0")); - this.rbSelectingMethod.Items.Add(new ListItem(Localization.GetString("Slow.Text", this.LocalResourceFile), "1")); + rbSelectingMethod.Items.Add(new ListItem(Localization.GetString("Fast.Text", LocalResourceFile), "0")); + rbSelectingMethod.Items.Add(new ListItem(Localization.GetString("Slow.Text", LocalResourceFile), "1")); - if (this.UserInfo.IsSuperUser) + if (UserInfo.IsSuperUser) { if (settings.IncludeHost != null) { - this.cbIncludeHostUser.Checked = (bool) settings.IncludeHost; + cbIncludeHostUser.Checked = (bool) settings.IncludeHost; } } else { - this.trHostSettings.Visible = false; + trHostSettings.Visible = false; } - this.rbSortBy.SelectedValue = ((int) settings.SortBy).ToString(); - this.rbSelectingMethod.SelectedValue = ((int) settings.UserSwitchingSpeed).ToString(); + rbSortBy.SelectedValue = ((int) settings.SortBy).ToString(); + rbSelectingMethod.SelectedValue = ((int) settings.UserSwitchingSpeed).ToString(); } } catch (Exception exception) //Module failed to load @@ -108,20 +108,20 @@ public override void UpdateSettings() try { var repository = new IdentitySwitcherModuleSettingsRepository(); - var settings = repository.GetSettings(this.ModuleConfiguration); + var settings = repository.GetSettings(ModuleConfiguration); - if (this.UserInfo.IsSuperUser) + if (UserInfo.IsSuperUser) { - settings.IncludeHost = this.cbIncludeHostUser.Checked; + settings.IncludeHost = cbIncludeHostUser.Checked; } - settings.SortBy = (SortBy) Enum.Parse(typeof(SortBy), this.rbSortBy.SelectedValue); + settings.SortBy = (SortBy) Enum.Parse(typeof(SortBy), rbSortBy.SelectedValue); settings.UserSwitchingSpeed = - (UserSwitchingSpeed) Enum.Parse(typeof(UserSwitchingSpeed), this.rbSelectingMethod.SelectedValue); + (UserSwitchingSpeed) Enum.Parse(typeof(UserSwitchingSpeed), rbSelectingMethod.SelectedValue); - repository.SaveSettings(this.ModuleConfiguration, settings); + repository.SaveSettings(ModuleConfiguration, settings); // refresh cache - ModuleController.SynchronizeModule(this.ModuleId); + ModuleController.SynchronizeModule(ModuleId); } catch (Exception exception) //Module failed to load { diff --git a/ViewIdentitySwitcher.ascx.cs b/ViewIdentitySwitcher.ascx.cs index e5c132f..65e8cfc 100644 --- a/ViewIdentitySwitcher.ascx.cs +++ b/ViewIdentitySwitcher.ascx.cs @@ -81,12 +81,12 @@ private string ModuleFolderName { get { - if (string.IsNullOrWhiteSpace(this._moduleFolderName)) + if (string.IsNullOrWhiteSpace(_moduleFolderName)) { - this._moduleFolderName = - Path.Combine(Globals.DesktopModulePath, this.ModuleConfiguration.DesktopModule.FolderName); + _moduleFolderName = + Path.Combine(Globals.DesktopModulePath, ModuleConfiguration.DesktopModule.FolderName); } - return this._moduleFolderName; + return _moduleFolderName; } } @@ -96,7 +96,7 @@ private string ModuleFolderName /// /// The module script folder. /// - private string ModuleScriptFolder => Path.Combine(this.ModuleFolderName, this.ScriptFolderName); + private string ModuleScriptFolder => Path.Combine(ModuleFolderName, ScriptFolderName); #endregion @@ -110,7 +110,7 @@ private void InitializeModuleInstanceJson(HtmlGenericControl initControl) if (initControl != null) { var initScript = string.Format(CultureInfo.InvariantCulture, "vm.init({0})", - this.GetModuleInstance().ToJson()); + GetModuleInstance().ToJson()); initControl.Attributes.Add("ng-init", initScript); } @@ -125,7 +125,7 @@ private void InitializeModuleInstanceJson(HtmlGenericControl initControl) private void RegisterScript(string folder, string fileName, int priority) { var scriptPath = string.IsNullOrWhiteSpace(folder) ? fileName : Path.Combine(folder, fileName); - ClientResourceManager.RegisterScript(this.Page, scriptPath, priority); + ClientResourceManager.RegisterScript(Page, scriptPath, priority); } /// @@ -134,7 +134,7 @@ private void RegisterScript(string folder, string fileName, int priority) /// private ModuleInstanceBase GetModuleInstance() { - return this.GetModuleInstance(this); + return GetModuleInstance(this); } /// @@ -152,8 +152,8 @@ private TModuleInstance GetModuleInstance(PortalModuleBase modu { result.ModuleID = moduleControl.ModuleId; result.PortalId = moduleControl.PortalId; - result.FilterText = Localization.GetString("FilterText.Text", this.LocalResourceFile); - result.SwitchToText = Localization.GetString("SwitchToText.Text", this.LocalResourceFile); + result.FilterText = Localization.GetString("FilterText.Text", LocalResourceFile); + result.SwitchToText = Localization.GetString("SwitchToText.Text", LocalResourceFile); var moduleInfo = new ModuleController().GetModule(moduleControl.ModuleId); var repository = new IdentitySwitcherModuleSettingsRepository(); @@ -177,13 +177,13 @@ private void Page_Init(object sender, EventArgs e) var priority = 0; //Javascript Resources - var jsFolder = Path.Combine(this.ModuleScriptFolder, ResourcesFolderName); - this.RegisterScript(jsFolder, "angular.min.js", priority++); - this.RegisterScript(jsFolder, "angular-resource.min.js", priority++); + var jsFolder = Path.Combine(ModuleScriptFolder, ResourcesFolderName); + RegisterScript(jsFolder, "angular.min.js", priority++); + RegisterScript(jsFolder, "angular-resource.min.js", priority++); //Typescript - jsFolder = Path.Combine(this.ModuleScriptFolder, DistributionFolderName); - this.RegisterScript(jsFolder, "dnn.identityswitcher.js", priority++); + jsFolder = Path.Combine(ModuleScriptFolder, DistributionFolderName); + RegisterScript(jsFolder, "dnn.identityswitcher.js", priority++); } catch (Exception exception) @@ -201,9 +201,9 @@ private void Page_Load(object sender, EventArgs e) { try { - if (!this.Page.IsPostBack) + if (!Page.IsPostBack) { - this.InitializeModuleInstanceJson(this.divBaseDiv); + InitializeModuleInstanceJson(divBaseDiv); } } catch (Exception exception) //Module failed to load