From 289bbcb1f4d1340858b40f929f3b025f5419db04 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Fri, 20 Jan 2017 20:11:09 +0100 Subject: [PATCH] More on Impersonation --- Site/App_GlobalResources/Global.designer.cs | 18 ++++++++ Site/App_GlobalResources/Global.resx | 8 ++++ .../Pages.Admin.designer.cs | 45 +++++++++++++++++++ Site/App_GlobalResources/Pages.Admin.resx | 15 +++++++ Site/Bases/ControlV5Base.cs | 18 +++++++- Site/Bases/PageV5Base.cs | 15 +++++++ .../Pages/v5/Admin/CommenceImpersonation.aspx | 33 +++++++++++++- .../v5/Admin/CommenceImpersonation.aspx.cs | 9 ++-- 8 files changed, 154 insertions(+), 7 deletions(-) diff --git a/Site/App_GlobalResources/Global.designer.cs b/Site/App_GlobalResources/Global.designer.cs index 01006396..87dbfb12 100644 --- a/Site/App_GlobalResources/Global.designer.cs +++ b/Site/App_GlobalResources/Global.designer.cs @@ -1185,6 +1185,15 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to Ok. + /// + internal static string Global_Ok { + get { + return ResourceManager.GetString("Global_Ok", resourceCulture); + } + } + /// /// Looks up a localized string similar to On. /// @@ -1257,6 +1266,15 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to Proceed. + /// + internal static string Global_Proceed { + get { + return ResourceManager.GetString("Global_Proceed", resourceCulture); + } + } + /// /// Looks up a localized string similar to Processing File.... /// diff --git a/Site/App_GlobalResources/Global.resx b/Site/App_GlobalResources/Global.resx index e6db6d90..dfe65b54 100644 --- a/Site/App_GlobalResources/Global.resx +++ b/Site/App_GlobalResources/Global.resx @@ -894,6 +894,14 @@ Go As in "execute", "run requested procedure" + + Ok + Shown on confirmation dialogs + + + Proceed + Shown as "Ok" on some "Are you sure?" dialogs + Type a partial name... diff --git a/Site/App_GlobalResources/Pages.Admin.designer.cs b/Site/App_GlobalResources/Pages.Admin.designer.cs index 411908ca..21c8110b 100644 --- a/Site/App_GlobalResources/Pages.Admin.designer.cs +++ b/Site/App_GlobalResources/Pages.Admin.designer.cs @@ -150,6 +150,15 @@ namespace Resources.Pages { } } + /// + /// Looks up a localized string similar to <strong>IMPERSONATE PERSON?</strong><br/><br/>This is not to be taken lightly and may even be illegal depending on local laws.<br/><br/>The purpose of this tool is to fix technical malfunctions. Everything is logged.<br/><br/>Proceed?. + /// + internal static string CommenceImpersonation_Confirm { + get { + return ResourceManager.GetString("CommenceImpersonation_Confirm", resourceCulture); + } + } + /// /// Looks up a localized string similar to <strong>IMPERSONATION TERMINATED</strong><br/><br/>Impersonation terminated at {0:HH:mm} UTC. You are acting as yourself again.. /// @@ -159,6 +168,42 @@ namespace Resources.Pages { } } + /// + /// Looks up a localized string similar to <strong>IMPERSONATION DENIED</strong><br/><br/>You may not impersonate somebody who is your direct manager.. + /// + internal static string CommenceImpersonation_Error_Authority_Report { + get { + return ResourceManager.GetString("CommenceImpersonation_Error_Authority_Report", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to <strong>IMPERSONATION DENIED</strong><br/><br/>You may not impersonate somebody else with system level access.. + /// + internal static string CommenceImpersonation_Error_Authority_System { + get { + return ResourceManager.GetString("CommenceImpersonation_Error_Authority_System", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You need to select a person to impersonate.. + /// + internal static string CommenceImpersonation_Error_SelectPerson { + get { + return ResourceManager.GetString("CommenceImpersonation_Error_SelectPerson", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to If you need to impersonate yourself, we suggest you log off Swarmops and seek other kind of assistance.. + /// + internal static string CommenceImpersonation_Error_Self { + get { + return ResourceManager.GetString("CommenceImpersonation_Error_Self", resourceCulture); + } + } + /// /// Looks up a localized string similar to <strong>IMPERSONATION DENIED</strong><br/><br/>You do not seem to have sufficient privileges to impersonate somebody else.. /// diff --git a/Site/App_GlobalResources/Pages.Admin.resx b/Site/App_GlobalResources/Pages.Admin.resx index 4017b129..4dab74e8 100644 --- a/Site/App_GlobalResources/Pages.Admin.resx +++ b/Site/App_GlobalResources/Pages.Admin.resx @@ -322,10 +322,25 @@ You have an active impersonation session as {0}. <a href="javascript:terminateImpersonation();">End impersonation.</a> Visible on Dashboard. {0} is the impersonated name. + + <strong>IMPERSONATE PERSON?</strong><br/><br/>This is not to be taken lightly and may even be illegal depending on local laws.<br/><br/>The purpose of this tool is to fix technical malfunctions. Everything is logged.<br/><br/>Proceed? + <strong>IMPERSONATION TERMINATED</strong><br/><br/>Impersonation terminated at {0:HH:mm} UTC. You are acting as yourself again. {0} will be fed with a DateTime. The colon is rewritten automatically into the current DateTimeFormatInfo.TimeSeparator. + + <strong>IMPERSONATION DENIED</strong><br/><br/>You may not impersonate somebody who is your direct manager. + + + <strong>IMPERSONATION DENIED</strong><br/><br/>You may not impersonate somebody else with system level access. + + + You need to select a person to impersonate. + + + If you need to impersonate yourself, we suggest you log off Swarmops and seek other kind of assistance. + <strong>IMPERSONATION DENIED</strong><br/><br/>You do not seem to have sufficient privileges to impersonate somebody else. diff --git a/Site/Bases/ControlV5Base.cs b/Site/Bases/ControlV5Base.cs index c7cd4e29..da5878d1 100644 --- a/Site/Bases/ControlV5Base.cs +++ b/Site/Bases/ControlV5Base.cs @@ -46,16 +46,30 @@ namespace Swarmops.Frontend - // ReSharper disable once InconsistentNaming + // ReSharper disable InconsistentNaming public string Localized_AjaxCallException { get { return JavascriptEscape (Resources.Global.Error_AjaxCallException); } } - // ReSharper disable once InconsistentNaming public string Localized_AjaxGeneralErrorSettingValue { get { return JavascriptEscape (Resources.Global.Error_UnspecifiedAjaxSetValue); } } + + public string Localized_ConfirmDialog_Ok + { + get { return JavascriptEscape(Resources.Global.Global_Ok); } + } + + public string Localized_ConfirmDialog_Proceed + { + get { return JavascriptEscape(Resources.Global.Global_Proceed); } + } + + public string Localized_ConfirmDialog_Cancel + { + get { return JavascriptEscape(Resources.Global.Global_Cancel); } + } } } \ No newline at end of file diff --git a/Site/Bases/PageV5Base.cs b/Site/Bases/PageV5Base.cs index fb635f85..ef74dc47 100644 --- a/Site/Bases/PageV5Base.cs +++ b/Site/Bases/PageV5Base.cs @@ -189,6 +189,21 @@ namespace Swarmops.Frontend get { return JavascriptEscape(Resources.Global.Global_Off.ToUpperInvariant()); } } + public string Localized_ConfirmDialog_Ok + { + get { return JavascriptEscape(Resources.Global.Global_Ok); } + } + + public string Localized_ConfirmDialog_Proceed + { + get { return JavascriptEscape(Resources.Global.Global_Proceed); } + } + + public string Localized_ConfirmDialog_Cancel + { + get { return JavascriptEscape(Resources.Global.Global_Cancel); } + } + } diff --git a/Site/Pages/v5/Admin/CommenceImpersonation.aspx b/Site/Pages/v5/Admin/CommenceImpersonation.aspx index aa9567db..2b56be17 100644 --- a/Site/Pages/v5/Admin/CommenceImpersonation.aspx +++ b/Site/Pages/v5/Admin/CommenceImpersonation.aspx @@ -9,9 +9,40 @@ $(document).ready(function () { - }); + function dialogBeginImpersonation() { + alertify.set({ + labels: { + ok: SwarmopsJS.unescape('<%=this.Localized_ConfirmDialog_Proceed%>'), + cancel: SwarmopsJS.unescape('<%=this.Localized_ConfirmDialog_Cancel%>') + }, + buttonFocus: 'cancel' + }); + + alertify.confirm(SwarmopsJS.unescape('<%=this.Localized_ConfirmDialog_Text%>'), + $.proxy(function (response) { + if (response) { + var selectedPersonId = <%=this.ComboPeople.ClientID%>_selectedPersonId(); + SwarmopsJS.ajaxCall("/Pages/v5/Admin/CommenceImpersonation.aspx/Commence", + { personId: selectedPersonId }, + function(result) { + // if Success is true, we have a new auth cookie and should redir to Dashboard, + // otherwise, we should dialog the returned DisplayMessage + if (result.Success) { + document.location = "/"; // redirect + } else { + alert.dialog(result.DisplayMessage); + } + + + }); + } else { + // Do nothing on cancel + } + }, this)); + } + diff --git a/Site/Pages/v5/Admin/CommenceImpersonation.aspx.cs b/Site/Pages/v5/Admin/CommenceImpersonation.aspx.cs index da1adb96..858cf85a 100644 --- a/Site/Pages/v5/Admin/CommenceImpersonation.aspx.cs +++ b/Site/Pages/v5/Admin/CommenceImpersonation.aspx.cs @@ -37,7 +37,7 @@ namespace Swarmops.Frontend.Pages.v5.Admin [WebMethod] - public static AjaxCallResult BeginImpersonation (int personId) + public static AjaxCallResult Commence (int personId) { AuthenticationData authData = GetAuthenticationDataAndCulture(); @@ -80,11 +80,12 @@ namespace Swarmops.Frontend.Pages.v5.Admin // ReSharper disable InconsistentNaming - public string Localized_ValidationError_MissingTag + public string Localized_ConfirmDialog_Text { - get { return JavascriptEscape(Resources.Pages.Financial.FileExpenseClaim_ValidationError_MissingTag); } + get { return JavascriptEscape(Resources.Pages.Admin.CommenceImpersonation_Confirm); } } + /* public string Localized_ValidationError_BankAccount { get { return JavascriptEscape(Resources.Pages.Financial.RequestCashAdvance_ValidationError_BankAccount); } @@ -118,7 +119,7 @@ namespace Swarmops.Frontend.Pages.v5.Admin public string Localized_ValidationError_Documents { get { return JavascriptEscape(Resources.Pages.Financial.FileExpenseClaim_ValidationError_Documents); } - } + }*/ } } \ No newline at end of file