Work on Reset Password (incl style fix)

This commit is contained in:
Rick Falkvinge
2016-10-17 14:43:07 +02:00
parent 170c4b1abf
commit 1f4e1929a8
6 changed files with 157 additions and 30 deletions
+46 -1
View File
@@ -1482,6 +1482,24 @@ namespace Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Reset User Password?.
/// </summary>
internal static string Master_EditPersonResetPasswordConfirm_Header {
get {
return ResourceManager.GetString("Master_EditPersonResetPasswordConfirm_Header", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You&apos;re resetting a user password. This user will receive a reset link by mail, which they can click to reset their Swarmops password.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Never do this unless specifically asked for assistance with this by the user.&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;Proceed with password reset procedure?.
/// </summary>
internal static string Master_EditPersonResetPasswordConfirm_Text {
get {
return ResourceManager.GetString("Master_EditPersonResetPasswordConfirm_Text", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Mail a password-reset link.
/// </summary>
@@ -1492,7 +1510,34 @@ namespace Resources {
}
/// <summary>
/// Looks up a localized string similar to This doesn&apos;t look like a valid phone number, but we&apos;re storing it as written here..
/// Looks up a localized string similar to Password Reset Prohibited.
/// </summary>
internal static string Master_EditPersonResetPasswordProhibited_Header {
get {
return ResourceManager.GetString("Master_EditPersonResetPasswordProhibited_Header", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to This user&apos;s mail address was recently changed (less than a week ago). For security reasons, a password reset link cannot and will not be sent to such a newly changed mail address..
/// </summary>
internal static string Master_EditPersonResetPasswordProhibited_Text {
get {
return ResourceManager.GetString("Master_EditPersonResetPasswordProhibited_Text", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to A password reset link was sent to this user..
/// </summary>
internal static string Master_EditPersonResetPassword_ResetLinkSent {
get {
return ResourceManager.GetString("Master_EditPersonResetPassword_ResetLinkSent", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to This doesn&apos;t look like a valid phone number, but we&apos;re storing it as written here nonetheless..
/// </summary>
internal static string Master_EditPersonWarning_Phone {
get {
+17 -2
View File
@@ -756,7 +756,22 @@
<value>Mail a password-reset link</value>
</data>
<data name="Master_EditPersonWarning_Phone" xml:space="preserve">
<value>This doesn't look like a valid phone number, but we're storing it as written here.</value>
<comment>Trigges as a notice if phone misses a regexp.</comment>
<value>This doesn't look like a valid phone number, but we're storing it as written here nonetheless.</value>
<comment>Triggers as a notice if phone misses a regexp of 0-9, (), -, +, and space.</comment>
</data>
<data name="Master_EditPersonResetPasswordConfirm_Header" xml:space="preserve">
<value>Reset User Password?</value>
</data>
<data name="Master_EditPersonResetPasswordConfirm_Text" xml:space="preserve">
<value>You're resetting a user password. This user will receive a reset link by mail, which they can click to reset their Swarmops password.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Never do this unless specifically asked for assistance with this by the user.&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;Proceed with password reset procedure?</value>
</data>
<data name="Master_EditPersonResetPasswordProhibited_Header" xml:space="preserve">
<value>Password Reset Prohibited</value>
</data>
<data name="Master_EditPersonResetPasswordProhibited_Text" xml:space="preserve">
<value>This user's mail address was recently changed (less than a week ago). For security reasons, a password reset link cannot and will not be sent to such a newly changed mail address.</value>
</data>
<data name="Master_EditPersonResetPassword_ResetLinkSent" xml:space="preserve">
<value>A password reset link was sent to this user.</value>
</data>
</root>
+9 -2
View File
@@ -272,12 +272,16 @@ namespace Swarmops.Frontend.Automation
AuthenticationData authData = GetAuthenticationDataAndCulture();
bool self = false;
// Are we modifying ourselves?
if (personId == 0) // request self record
{
self = true; // may make use of this later
personId = authData.CurrentUser.Identity;
}
// Preliminary input validation
if (string.IsNullOrEmpty (newValue))
{
if (field != "TwitterId") // These fields may be set to empty; default is disallow
@@ -292,7 +296,7 @@ namespace Swarmops.Frontend.Automation
}
}
// TODO: Verify authority to see and change personal data
// Verify authority to see and change personal data
Person affectedPerson = Person.FromIdentity (personId);
@@ -308,7 +312,10 @@ namespace Swarmops.Frontend.Automation
string oldValue;
string displayMessage = string.Empty;
newValue = newValue.Trim().Replace (" ", " ");
while (newValue.Contains (" "))
{
newValue = newValue.Trim().Replace (" ", " "); // double, triple, quadruple spaces reduced to one
}
switch (field)
{
+50 -25
View File
@@ -1,4 +1,5 @@
<%@ Master Language="C#" AutoEventWireup="true" Inherits="Swarmops.Frontend.MasterV5" Codebehind="Master-v5.master.cs" %>
<%@ Import Namespace="System.Runtime.CompilerServices" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -50,8 +51,11 @@
<asp:ContentPlaceHolder id="PlaceHolderHead" runat="server" />
<asp:Literal ID="LiteralCrowdinScript" runat="server" Text="" />
<!-- initialize all jQuery stuff -->
<!-- initialize all jQuery stuff and localize -->
<script language="javascript" type="text/javascript">
var localizedMasterEditResetPasswordButton = SwarmopsJS.unescape('<%= this.Localized_MasterPersonEditResetPasswordButton %>');
$(document).ready(function () {/*
$('#LinkChangeOrganizations').qtip(
{
@@ -93,10 +97,13 @@
speed: 'fast', // faster animation speed
});
$('#masterPersonEditButtonResetPassword').val(localizedMasterEditResetPasswordButton);
<asp:Literal runat="server" ID="LiteralDocumentReadyHook" />
});
</script>
<!-- initialize tooltips -->
@@ -131,7 +138,7 @@
<div class="center980px">
<div class="currentuserinfo">
<div style="background-image:url('/Images/Icons/iconshock-user-16px.png');background-repeat:no-repeat;padding-left:16px;float:left"><a href="javascript:masterBeginEditPerson(0);"><asp:Label ID="LabelCurrentUserName" runat="server" /></a> | </div>
<div style="background-image:url('/Images/Icons/iconshock-user-16px.png');background-repeat:no-repeat;padding-left:16px;float:left"><a href="javascript:masterBeginEditPerson(0);"><span class="spanUser<%=this.CurrentUser.Identity %>Name spanUser0Name"><asp:Label ID="LabelCurrentUserName" runat="server" /></span></a> | </div>
<div style="background-image:url('/Images/Icons/iconshock-workchair-16px.png');background-repeat:no-repeat;padding-left:17px;float:left"><span class="hasTooltip" rel="Logged into <%=this.CurrentOrganization.Name %>" title="Click here to switch to another organization."><a href="/Security/ChangeOrganizations" id="LinkChangeOrganizations"><asp:Label ID="LabelCurrentOrganizationName" runat="server" /></a></span> |&nbsp;</div>
<div style="background-image:url('/Images/Icons/iconshock-gamepad-16px.png');background-repeat:no-repeat;padding-left:20px;float:left" id="divUserPreferences"><asp:Label ID="LabelPreferences" runat="server" /> | </div>
<div style="background-image:url('/Images/Icons/iconshock-lock-16px.png');background-repeat:no-repeat;padding-left:16px;float:left"><asp:LinkButton ID="LinkLogout" runat="server" OnClick="LinkLogout_Click" /> |&nbsp;</div>
@@ -249,7 +256,7 @@
<div title="<img src='/Images/Icons/iconshock-lock-256px.png' height='64' width='64' />">
<h2><span class="spanModalEditingPersonName">PERSONNAME</span>: <asp:Label ID="MasterLabelEditPersonHeaderSecurityProvisioning" runat="server" /></h2>
<div class="entryFields">
<input type="button" value="#SendResetMail#" />&#8203;<br/>
<input type="button" id="masterPersonEditButtonResetPassword" onclick="masterPersonEditorConfirmResetPassword(); return false;" value="#SendResetMail#" />&#8203;<br/>
<input type="input" todo="true"/>
</div>
<div class="entryLabels">
@@ -414,27 +421,30 @@
// HACK: Possible race condition for "controlName" here in some environments?
"/Automation/SwarmFunctions.aspx/SetPersonEditorData",
jsonData,
function(result) {
console.log(result);
if (result.Success) {
window[controlName + "_updateSuccessAnimate"](result.NewValue);
if (result.DisplayMessage != '') {
alertify.log(result.DisplayMessage);
}
} else {
window[controlName + "_updateFailAnimate"](result.NewValue);
if (result.DisplayMessage != '') {
alertify.error(result.DisplayMessage);
}
}
},
function(result) {
console.log(result);
alert('fail');
window[controlName + "_updateFailAnimate"](result.NewValue);
});
"/Automation/SwarmFunctions.aspx/SetPersonEditorData",
jsonData,
function(result) {
console.log(result);
if (result.Success) {
window[controlName + "_updateSuccessAnimate"](result.NewValue);
if (result.DisplayMessage != '') {
alertify.log(result.DisplayMessage);
}
if (fieldName == "Name") {
$('span.spanUser' + _master_PersonEditedId + 'Name').text(result.NewValue);
}
} else {
window[controlName + "_updateFailAnimate"](result.NewValue);
if (result.DisplayMessage != '') {
alertify.error(result.DisplayMessage);
}
}
},
function(result) {
console.log(result);
alert('fail');
window[controlName + "_updateFailAnimate"](result.NewValue);
});
@@ -446,6 +456,21 @@
_master_PersonEditedId = -1; // no person being edited anymore
}
function masterPersonEditorConfirmResetPassword() {
alertify.set({
labels: {
ok: SwarmopsJS.unescape('<%=this.Localized_Confirm%>'),
cancel: SwarmopsJS.unescape('<%=this.Localized_Cancel%>')
}
});
alertify.confirm('<strong>' + SwarmopsJS.unescape('<%=this.Localized_MasterPersonEditResetPasswordConfirm_Header%>') + '</strong><br/><br/>' + SwarmopsJS.unescape('<%=this.Localized_MasterPersonEditResetPasswordConfirm_Text%>'), function () { alert("Ding!"); }, function () { // cancel, do nothing
});
}
</script>
</form>
+31
View File
@@ -430,5 +430,36 @@ namespace Swarmops.Frontend
{
get { return CommonV5.JavascriptEscape(Resources.Global.Master_EditPersonResetPasswordButton); }
}
public string Localized_MasterPersonEditResetPasswordConfirm_Header
{
get { return CommonV5.JavascriptEscape(Resources.Global.Master_EditPersonResetPasswordConfirm_Header); }
}
public string Localized_MasterPersonEditResetPasswordConfirm_Text
{
get { return CommonV5.JavascriptEscape(Resources.Global.Master_EditPersonResetPasswordConfirm_Text); }
}
public string Localized_MasterPersonEditResetPasswordProhibited_Header
{
get { return CommonV5.JavascriptEscape(Resources.Global.Master_EditPersonResetPasswordProhibited_Header); }
}
public string Localized_MasterPersonEditResetPasswordProhibited_Text
{
get { return CommonV5.JavascriptEscape(Resources.Global.Master_EditPersonResetPasswordProhibited_Text); }
}
public string Localized_Cancel
{
get { return CommonV5.JavascriptEscape (Resources.Global.Global_Cancel); }
}
public string Localized_Confirm
{
get { return CommonV5.JavascriptEscape(Resources.Global.Global_Confirm); }
}
}
}
+4
View File
@@ -680,6 +680,10 @@ body.rtl div.modal .entryFields {
box-shadow: 0px 0px 4px 2px #1C397E inset;
}
.entryFields > input[type=button] {
width: 324px;
}
.entryLabels
{