Change username and password of other users
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -35,12 +35,14 @@ namespace OpenSaveCloudClient.Core
|
|||||||
{
|
{
|
||||||
Log log = new()
|
Log log = new()
|
||||||
{
|
{
|
||||||
|
Timestamp = DateTime.Now,
|
||||||
Message = message,
|
Message = message,
|
||||||
Severity = LogSeverity.Error,
|
Severity = LogSeverity.Error,
|
||||||
};
|
};
|
||||||
messages.Add(log);
|
messages.Add(log);
|
||||||
NewMessageEventArgs args = new()
|
NewMessageEventArgs args = new()
|
||||||
{
|
{
|
||||||
|
Timestamp = DateTime.Now,
|
||||||
Message = message,
|
Message = message,
|
||||||
Severity = LogSeverity.Error,
|
Severity = LogSeverity.Error,
|
||||||
};
|
};
|
||||||
@@ -51,12 +53,14 @@ namespace OpenSaveCloudClient.Core
|
|||||||
{
|
{
|
||||||
Log log = new()
|
Log log = new()
|
||||||
{
|
{
|
||||||
|
Timestamp = DateTime.Now,
|
||||||
Message = message,
|
Message = message,
|
||||||
Severity = LogSeverity.Information,
|
Severity = LogSeverity.Information,
|
||||||
};
|
};
|
||||||
messages.Add(log);
|
messages.Add(log);
|
||||||
NewMessageEventArgs args = new()
|
NewMessageEventArgs args = new()
|
||||||
{
|
{
|
||||||
|
Timestamp = DateTime.Now,
|
||||||
Message = message,
|
Message = message,
|
||||||
Severity = LogSeverity.Information,
|
Severity = LogSeverity.Information,
|
||||||
};
|
};
|
||||||
@@ -67,12 +71,14 @@ namespace OpenSaveCloudClient.Core
|
|||||||
{
|
{
|
||||||
Log log = new()
|
Log log = new()
|
||||||
{
|
{
|
||||||
|
Timestamp = DateTime.Now,
|
||||||
Message = message,
|
Message = message,
|
||||||
Severity = LogSeverity.Warning,
|
Severity = LogSeverity.Warning,
|
||||||
};
|
};
|
||||||
messages.Add(log);
|
messages.Add(log);
|
||||||
NewMessageEventArgs args = new()
|
NewMessageEventArgs args = new()
|
||||||
{
|
{
|
||||||
|
Timestamp = DateTime.Now,
|
||||||
Message = message,
|
Message = message,
|
||||||
Severity = LogSeverity.Warning,
|
Severity = LogSeverity.Warning,
|
||||||
};
|
};
|
||||||
@@ -110,6 +116,7 @@ namespace OpenSaveCloudClient.Core
|
|||||||
|
|
||||||
public class NewMessageEventArgs : EventArgs
|
public class NewMessageEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
public DateTime Timestamp { get; set; }
|
||||||
public string Message { get; set; }
|
public string Message { get; set; }
|
||||||
public LogSeverity Severity { get; set; }
|
public LogSeverity Severity { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ namespace OpenSaveCloudClient.Core
|
|||||||
return JsonSerializer.Deserialize<Game>(responseText);
|
return JsonSerializer.Deserialize<Game>(responseText);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
logManager.AddError(String.Format("Received HTTP Status {0} from the server", response.StatusCode.ToString()));
|
LogServerError(response);
|
||||||
}
|
}
|
||||||
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
||||||
}
|
}
|
||||||
@@ -365,7 +365,7 @@ namespace OpenSaveCloudClient.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logManager.AddError(String.Format("Received HTTP Status {0} from the server", response.StatusCode.ToString()));
|
LogServerError(response);
|
||||||
}
|
}
|
||||||
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
||||||
}
|
}
|
||||||
@@ -399,7 +399,7 @@ namespace OpenSaveCloudClient.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logManager.AddError(String.Format("Received HTTP Status {0} from the server", response.StatusCode.ToString()));
|
LogServerError(response);
|
||||||
}
|
}
|
||||||
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
||||||
}
|
}
|
||||||
@@ -449,7 +449,7 @@ namespace OpenSaveCloudClient.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logManager.AddError(String.Format("Received HTTP Status {0} from the server", response.StatusCode.ToString()));
|
LogServerError(response);
|
||||||
}
|
}
|
||||||
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
||||||
}
|
}
|
||||||
@@ -518,7 +518,7 @@ namespace OpenSaveCloudClient.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logManager.AddError(String.Format("Received HTTP Status {0} from the server", response.StatusCode.ToString()));
|
LogServerError(response);
|
||||||
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -547,7 +547,7 @@ namespace OpenSaveCloudClient.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logManager.AddError(String.Format("Received HTTP Status {0} from the server", response.StatusCode.ToString()));
|
LogServerError(response);
|
||||||
}
|
}
|
||||||
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
||||||
}
|
}
|
||||||
@@ -576,7 +576,7 @@ namespace OpenSaveCloudClient.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logManager.AddError(String.Format("Received HTTP Status {0} from the server", response.StatusCode.ToString()));
|
LogServerError(response);
|
||||||
}
|
}
|
||||||
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
||||||
}
|
}
|
||||||
@@ -608,7 +608,7 @@ namespace OpenSaveCloudClient.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logManager.AddError(String.Format("Received HTTP Status {0} from the server", response.StatusCode.ToString()));
|
LogServerError(response);
|
||||||
}
|
}
|
||||||
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
||||||
}
|
}
|
||||||
@@ -637,7 +637,7 @@ namespace OpenSaveCloudClient.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logManager.AddError(String.Format("Received HTTP Status {0} from the server", response.StatusCode.ToString()));
|
LogServerError(response);
|
||||||
}
|
}
|
||||||
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
||||||
}
|
}
|
||||||
@@ -667,7 +667,7 @@ namespace OpenSaveCloudClient.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logManager.AddError(String.Format("Received HTTP Status {0} from the server", response.StatusCode.ToString()));
|
LogServerError(response);
|
||||||
}
|
}
|
||||||
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
||||||
}
|
}
|
||||||
@@ -696,7 +696,7 @@ namespace OpenSaveCloudClient.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logManager.AddError(String.Format("Received HTTP Status {0} from the server", response.StatusCode.ToString()));
|
LogServerError(response);
|
||||||
}
|
}
|
||||||
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
||||||
}
|
}
|
||||||
@@ -728,7 +728,7 @@ namespace OpenSaveCloudClient.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logManager.AddError(String.Format("Received HTTP Status {0} from the server", response.StatusCode.ToString()));
|
LogServerError(response);
|
||||||
}
|
}
|
||||||
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
||||||
}
|
}
|
||||||
@@ -740,7 +740,7 @@ namespace OpenSaveCloudClient.Core
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ChangePassword(int userId, NewPassword password)
|
public bool ChangePassword(long userId, NewPassword password)
|
||||||
{
|
{
|
||||||
logManager.AddInformation(string.Format("Changing password of user {0}", userId));
|
logManager.AddInformation(string.Format("Changing password of user {0}", userId));
|
||||||
string uuidTask = taskManager.StartTask("Changing password", true, 1);
|
string uuidTask = taskManager.StartTask("Changing password", true, 1);
|
||||||
@@ -760,7 +760,39 @@ namespace OpenSaveCloudClient.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logManager.AddError(String.Format("Received HTTP Status {0} from the server", response.StatusCode.ToString()));
|
LogServerError(response);
|
||||||
|
}
|
||||||
|
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logManager.AddError(ex);
|
||||||
|
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ChangeUsername(UpdateUsername newUserInfo)
|
||||||
|
{
|
||||||
|
logManager.AddInformation(string.Format("Changing username of user {0}", newUserInfo.Id));
|
||||||
|
string uuidTask = taskManager.StartTask("Changing username", true, 1);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HttpClient client = new();
|
||||||
|
string json = JsonSerializer.Serialize(newUserInfo);
|
||||||
|
HttpContent content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||||
|
client.DefaultRequestHeaders.Add("Authorization", "bearer " + token);
|
||||||
|
HttpResponseMessage response = client.PostAsync(string.Format("{0}:{1}/api/v1/admin/user/username", host, port), content).Result;
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
logManager.AddInformation("Username changed");
|
||||||
|
string responseText = response.Content.ReadAsStringAsync().Result;
|
||||||
|
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Ended);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogServerError(response);
|
||||||
}
|
}
|
||||||
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
||||||
}
|
}
|
||||||
@@ -819,7 +851,7 @@ namespace OpenSaveCloudClient.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logManager.AddError(String.Format("Received HTTP Status {0} from the server", response.StatusCode.ToString()));
|
LogServerError(response);
|
||||||
}
|
}
|
||||||
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
||||||
}
|
}
|
||||||
@@ -896,6 +928,19 @@ namespace OpenSaveCloudClient.Core
|
|||||||
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LogServerError(HttpResponseMessage response)
|
||||||
|
{
|
||||||
|
string responseText = response.Content.ReadAsStringAsync().Result;
|
||||||
|
HttpError? error = JsonSerializer.Deserialize<HttpError>(responseText);
|
||||||
|
if (error != null)
|
||||||
|
{
|
||||||
|
logManager.AddError(String.Format("[Server error][{0}] {1}", error.Status, error.Message));
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
logManager.AddError(String.Format("Received HTTP Status {0} from the server", response.StatusCode.ToString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// method <c>SaveToConfig</c> save the server connection information to the configuration file
|
/// method <c>SaveToConfig</c> save the server connection information to the configuration file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
26
OpenSaveCloudClient/LogsForm.Designer.cs
generated
26
OpenSaveCloudClient/LogsForm.Designer.cs
generated
@@ -34,6 +34,7 @@
|
|||||||
this.Severity = new System.Windows.Forms.ColumnHeader();
|
this.Severity = new System.Windows.Forms.ColumnHeader();
|
||||||
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
|
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
|
||||||
this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
|
this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
|
||||||
|
this.Timestamp = new System.Windows.Forms.ColumnHeader();
|
||||||
this.toolStrip1.SuspendLayout();
|
this.toolStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
@@ -43,15 +44,15 @@
|
|||||||
| System.Windows.Forms.AnchorStyles.Left)
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||||
|
this.Timestamp,
|
||||||
this.Message,
|
this.Message,
|
||||||
this.Severity});
|
this.Severity});
|
||||||
this.listView1.GridLines = true;
|
this.listView1.GridLines = true;
|
||||||
this.listView1.Location = new System.Drawing.Point(0, 27);
|
this.listView1.Location = new System.Drawing.Point(0, 40);
|
||||||
this.listView1.Margin = new System.Windows.Forms.Padding(2);
|
|
||||||
this.listView1.MultiSelect = false;
|
this.listView1.MultiSelect = false;
|
||||||
this.listView1.Name = "listView1";
|
this.listView1.Name = "listView1";
|
||||||
this.listView1.ShowGroups = false;
|
this.listView1.ShowGroups = false;
|
||||||
this.listView1.Size = new System.Drawing.Size(747, 344);
|
this.listView1.Size = new System.Drawing.Size(1118, 514);
|
||||||
this.listView1.TabIndex = 0;
|
this.listView1.TabIndex = 0;
|
||||||
this.listView1.UseCompatibleStateImageBehavior = false;
|
this.listView1.UseCompatibleStateImageBehavior = false;
|
||||||
this.listView1.View = System.Windows.Forms.View.Details;
|
this.listView1.View = System.Windows.Forms.View.Details;
|
||||||
@@ -69,11 +70,13 @@
|
|||||||
// toolStrip1
|
// toolStrip1
|
||||||
//
|
//
|
||||||
this.toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
|
this.toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
|
||||||
|
this.toolStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
|
||||||
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.toolStripButton1});
|
this.toolStripButton1});
|
||||||
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
|
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
|
||||||
this.toolStrip1.Name = "toolStrip1";
|
this.toolStrip1.Name = "toolStrip1";
|
||||||
this.toolStrip1.Size = new System.Drawing.Size(746, 26);
|
this.toolStrip1.Padding = new System.Windows.Forms.Padding(0, 0, 3, 0);
|
||||||
|
this.toolStrip1.Size = new System.Drawing.Size(1119, 38);
|
||||||
this.toolStrip1.TabIndex = 1;
|
this.toolStrip1.TabIndex = 1;
|
||||||
this.toolStrip1.Text = "toolStrip1";
|
this.toolStrip1.Text = "toolStrip1";
|
||||||
//
|
//
|
||||||
@@ -83,20 +86,24 @@
|
|||||||
this.toolStripButton1.Font = new System.Drawing.Font("Segoe MDL2 Assets", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
this.toolStripButton1.Font = new System.Drawing.Font("Segoe MDL2 Assets", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
|
this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||||
this.toolStripButton1.Name = "toolStripButton1";
|
this.toolStripButton1.Name = "toolStripButton1";
|
||||||
this.toolStripButton1.Size = new System.Drawing.Size(32, 23);
|
this.toolStripButton1.Size = new System.Drawing.Size(46, 33);
|
||||||
this.toolStripButton1.Text = "";
|
this.toolStripButton1.Text = "";
|
||||||
this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click);
|
this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click);
|
||||||
//
|
//
|
||||||
|
// Timestamp
|
||||||
|
//
|
||||||
|
this.Timestamp.Text = "Timestamp";
|
||||||
|
this.Timestamp.Width = 140;
|
||||||
|
//
|
||||||
// LogsForm
|
// LogsForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(144F, 144F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||||
this.ClientSize = new System.Drawing.Size(746, 369);
|
this.ClientSize = new System.Drawing.Size(1119, 554);
|
||||||
this.Controls.Add(this.toolStrip1);
|
this.Controls.Add(this.toolStrip1);
|
||||||
this.Controls.Add(this.listView1);
|
this.Controls.Add(this.listView1);
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
this.Margin = new System.Windows.Forms.Padding(2);
|
this.MinimumSize = new System.Drawing.Size(750, 280);
|
||||||
this.MinimumSize = new System.Drawing.Size(507, 205);
|
|
||||||
this.Name = "LogsForm";
|
this.Name = "LogsForm";
|
||||||
this.Text = "Logs";
|
this.Text = "Logs";
|
||||||
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.LogForm_FormClosed);
|
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.LogForm_FormClosed);
|
||||||
@@ -115,5 +122,6 @@
|
|||||||
private ColumnHeader Severity;
|
private ColumnHeader Severity;
|
||||||
private ToolStrip toolStrip1;
|
private ToolStrip toolStrip1;
|
||||||
private ToolStripButton toolStripButton1;
|
private ToolStripButton toolStripButton1;
|
||||||
|
private ColumnHeader Timestamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,8 @@ namespace OpenSaveCloudClient
|
|||||||
{
|
{
|
||||||
this.Invoke((MethodInvoker)delegate
|
this.Invoke((MethodInvoker)delegate
|
||||||
{
|
{
|
||||||
ListViewItem lvi = listView1.Items.Add(e.Message);
|
ListViewItem lvi = listView1.Items.Add(e.Timestamp.ToString());
|
||||||
|
lvi.SubItems.Add(e.Message);
|
||||||
lvi.SubItems.Add(e.Severity.ToString());
|
lvi.SubItems.Add(e.Severity.ToString());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -47,7 +48,8 @@ namespace OpenSaveCloudClient
|
|||||||
{
|
{
|
||||||
foreach (Log l in logManager.Messages)
|
foreach (Log l in logManager.Messages)
|
||||||
{
|
{
|
||||||
ListViewItem lvi = listView1.Items.Add(l.Message);
|
ListViewItem lvi = listView1.Items.Add(l.Timestamp.ToString());
|
||||||
|
lvi.SubItems.Add(l.Message);
|
||||||
lvi.SubItems.Add(l.Severity.ToString());
|
lvi.SubItems.Add(l.Severity.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace OpenSaveCloudClient.Models
|
|||||||
|
|
||||||
public class Log
|
public class Log
|
||||||
{
|
{
|
||||||
|
public DateTime Timestamp { get; set; }
|
||||||
public string Message { get; set; }
|
public string Message { get; set; }
|
||||||
public LogSeverity Severity { get; set; }
|
public LogSeverity Severity { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
23
OpenSaveCloudClient/Models/Remote/HttpError.cs
Normal file
23
OpenSaveCloudClient/Models/Remote/HttpError.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OpenSaveCloudClient.Models.Remote
|
||||||
|
{
|
||||||
|
public class HttpError
|
||||||
|
{
|
||||||
|
[JsonPropertyName("status")]
|
||||||
|
public int Status { get; set; }
|
||||||
|
[JsonPropertyName("timestamp")]
|
||||||
|
public string Timestamp { get; set; }
|
||||||
|
[JsonPropertyName("error")]
|
||||||
|
public string Error { get; set; }
|
||||||
|
[JsonPropertyName("message")]
|
||||||
|
public string Message { get; set; }
|
||||||
|
[JsonPropertyName("path")]
|
||||||
|
public string Path { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
17
OpenSaveCloudClient/Models/Remote/UpdateUsername.cs
Normal file
17
OpenSaveCloudClient/Models/Remote/UpdateUsername.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OpenSaveCloudClient.Models.Remote
|
||||||
|
{
|
||||||
|
public class UpdateUsername
|
||||||
|
{
|
||||||
|
[JsonPropertyName("id")]
|
||||||
|
public long Id { get; set; }
|
||||||
|
[JsonPropertyName("username")]
|
||||||
|
public string Username { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -58,6 +58,16 @@ namespace OpenSaveCloudClient
|
|||||||
LockControls(false);
|
LockControls(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!PasswordTool.CheckRequirements(NewPasswordBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show(
|
||||||
|
"Passwords need at least 6 characters",
|
||||||
|
"Change password",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
LockControls(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
ThreadPool.QueueUserWorkItem(delegate
|
ThreadPool.QueueUserWorkItem(delegate
|
||||||
{
|
{
|
||||||
serverConnector.ChangePassword(new NewPassword { Password = NewPasswordBox.Text, VerifyPassword = PasswordAgainBox.Text });
|
serverConnector.ChangePassword(new NewPassword { Password = NewPasswordBox.Text, VerifyPassword = PasswordAgainBox.Text });
|
||||||
@@ -87,6 +97,10 @@ namespace OpenSaveCloudClient
|
|||||||
{
|
{
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
|
else if (!PasswordTool.CheckRequirements(NewPasswordBox.Text))
|
||||||
|
{
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
SavePasswordButton.Enabled = valid;
|
SavePasswordButton.Enabled = valid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
98
OpenSaveCloudClient/UserManagementForm.Designer.cs
generated
98
OpenSaveCloudClient/UserManagementForm.Designer.cs
generated
@@ -57,9 +57,10 @@
|
|||||||
| System.Windows.Forms.AnchorStyles.Left)));
|
| System.Windows.Forms.AnchorStyles.Left)));
|
||||||
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||||
this.name});
|
this.name});
|
||||||
this.listView1.Location = new System.Drawing.Point(12, 86);
|
this.listView1.Location = new System.Drawing.Point(18, 129);
|
||||||
|
this.listView1.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.listView1.Name = "listView1";
|
this.listView1.Name = "listView1";
|
||||||
this.listView1.Size = new System.Drawing.Size(234, 352);
|
this.listView1.Size = new System.Drawing.Size(349, 503);
|
||||||
this.listView1.TabIndex = 0;
|
this.listView1.TabIndex = 0;
|
||||||
this.listView1.UseCompatibleStateImageBehavior = false;
|
this.listView1.UseCompatibleStateImageBehavior = false;
|
||||||
this.listView1.View = System.Windows.Forms.View.Details;
|
this.listView1.View = System.Windows.Forms.View.Details;
|
||||||
@@ -78,10 +79,11 @@
|
|||||||
this.panel1.Controls.Add(this.AddButton);
|
this.panel1.Controls.Add(this.AddButton);
|
||||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
|
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
this.panel1.Location = new System.Drawing.Point(0, 0);
|
this.panel1.Location = new System.Drawing.Point(0, 0);
|
||||||
this.panel1.MaximumSize = new System.Drawing.Size(0, 80);
|
this.panel1.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.panel1.MinimumSize = new System.Drawing.Size(0, 80);
|
this.panel1.MaximumSize = new System.Drawing.Size(0, 120);
|
||||||
|
this.panel1.MinimumSize = new System.Drawing.Size(0, 120);
|
||||||
this.panel1.Name = "panel1";
|
this.panel1.Name = "panel1";
|
||||||
this.panel1.Size = new System.Drawing.Size(800, 80);
|
this.panel1.Size = new System.Drawing.Size(1191, 120);
|
||||||
this.panel1.TabIndex = 6;
|
this.panel1.TabIndex = 6;
|
||||||
//
|
//
|
||||||
// label2
|
// label2
|
||||||
@@ -89,9 +91,10 @@
|
|||||||
this.label2.AutoSize = true;
|
this.label2.AutoSize = true;
|
||||||
this.label2.Font = new System.Drawing.Font("Segoe UI", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
this.label2.Font = new System.Drawing.Font("Segoe UI", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
this.label2.ForeColor = System.Drawing.Color.LightGray;
|
this.label2.ForeColor = System.Drawing.Color.LightGray;
|
||||||
this.label2.Location = new System.Drawing.Point(138, 22);
|
this.label2.Location = new System.Drawing.Point(207, 33);
|
||||||
|
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||||
this.label2.Name = "label2";
|
this.label2.Name = "label2";
|
||||||
this.label2.Size = new System.Drawing.Size(20, 32);
|
this.label2.Size = new System.Drawing.Size(29, 48);
|
||||||
this.label2.TabIndex = 9;
|
this.label2.TabIndex = 9;
|
||||||
this.label2.Text = "|";
|
this.label2.Text = "|";
|
||||||
//
|
//
|
||||||
@@ -101,9 +104,10 @@
|
|||||||
this.DeleteButton.FlatAppearance.BorderSize = 0;
|
this.DeleteButton.FlatAppearance.BorderSize = 0;
|
||||||
this.DeleteButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
this.DeleteButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
this.DeleteButton.Font = new System.Drawing.Font("Segoe MDL2 Assets", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
this.DeleteButton.Font = new System.Drawing.Font("Segoe MDL2 Assets", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
this.DeleteButton.Location = new System.Drawing.Point(75, 3);
|
this.DeleteButton.Location = new System.Drawing.Point(112, 4);
|
||||||
|
this.DeleteButton.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.DeleteButton.Name = "DeleteButton";
|
this.DeleteButton.Name = "DeleteButton";
|
||||||
this.DeleteButton.Size = new System.Drawing.Size(57, 74);
|
this.DeleteButton.Size = new System.Drawing.Size(86, 111);
|
||||||
this.DeleteButton.TabIndex = 1;
|
this.DeleteButton.TabIndex = 1;
|
||||||
this.DeleteButton.Text = "\r\n\r\nDelete";
|
this.DeleteButton.Text = "\r\n\r\nDelete";
|
||||||
this.DeleteButton.UseVisualStyleBackColor = true;
|
this.DeleteButton.UseVisualStyleBackColor = true;
|
||||||
@@ -114,9 +118,10 @@
|
|||||||
this.UserSettingsButton.FlatAppearance.BorderSize = 0;
|
this.UserSettingsButton.FlatAppearance.BorderSize = 0;
|
||||||
this.UserSettingsButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
this.UserSettingsButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
this.UserSettingsButton.Font = new System.Drawing.Font("Segoe MDL2 Assets", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
this.UserSettingsButton.Font = new System.Drawing.Font("Segoe MDL2 Assets", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
this.UserSettingsButton.Location = new System.Drawing.Point(164, 3);
|
this.UserSettingsButton.Location = new System.Drawing.Point(246, 4);
|
||||||
|
this.UserSettingsButton.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.UserSettingsButton.Name = "UserSettingsButton";
|
this.UserSettingsButton.Name = "UserSettingsButton";
|
||||||
this.UserSettingsButton.Size = new System.Drawing.Size(57, 74);
|
this.UserSettingsButton.Size = new System.Drawing.Size(86, 111);
|
||||||
this.UserSettingsButton.TabIndex = 8;
|
this.UserSettingsButton.TabIndex = 8;
|
||||||
this.UserSettingsButton.Text = "\r\n\r\nMe";
|
this.UserSettingsButton.Text = "\r\n\r\nMe";
|
||||||
this.UserSettingsButton.UseVisualStyleBackColor = true;
|
this.UserSettingsButton.UseVisualStyleBackColor = true;
|
||||||
@@ -127,9 +132,10 @@
|
|||||||
this.AddButton.FlatAppearance.BorderSize = 0;
|
this.AddButton.FlatAppearance.BorderSize = 0;
|
||||||
this.AddButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
this.AddButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
this.AddButton.Font = new System.Drawing.Font("Segoe MDL2 Assets", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
this.AddButton.Font = new System.Drawing.Font("Segoe MDL2 Assets", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
this.AddButton.Location = new System.Drawing.Point(12, 3);
|
this.AddButton.Location = new System.Drawing.Point(18, 4);
|
||||||
|
this.AddButton.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.AddButton.Name = "AddButton";
|
this.AddButton.Name = "AddButton";
|
||||||
this.AddButton.Size = new System.Drawing.Size(57, 74);
|
this.AddButton.Size = new System.Drawing.Size(86, 111);
|
||||||
this.AddButton.TabIndex = 0;
|
this.AddButton.TabIndex = 0;
|
||||||
this.AddButton.Text = "\r\n\r\nAdd";
|
this.AddButton.Text = "\r\n\r\nAdd";
|
||||||
this.AddButton.UseVisualStyleBackColor = true;
|
this.AddButton.UseVisualStyleBackColor = true;
|
||||||
@@ -144,9 +150,11 @@
|
|||||||
this.groupBox1.Controls.Add(this.groupBox2);
|
this.groupBox1.Controls.Add(this.groupBox2);
|
||||||
this.groupBox1.Controls.Add(this.UsernameBox);
|
this.groupBox1.Controls.Add(this.UsernameBox);
|
||||||
this.groupBox1.Controls.Add(this.label4);
|
this.groupBox1.Controls.Add(this.label4);
|
||||||
this.groupBox1.Location = new System.Drawing.Point(252, 86);
|
this.groupBox1.Location = new System.Drawing.Point(378, 129);
|
||||||
|
this.groupBox1.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.groupBox1.Name = "groupBox1";
|
this.groupBox1.Name = "groupBox1";
|
||||||
this.groupBox1.Size = new System.Drawing.Size(536, 352);
|
this.groupBox1.Padding = new System.Windows.Forms.Padding(4);
|
||||||
|
this.groupBox1.Size = new System.Drawing.Size(804, 503);
|
||||||
this.groupBox1.TabIndex = 7;
|
this.groupBox1.TabIndex = 7;
|
||||||
this.groupBox1.TabStop = false;
|
this.groupBox1.TabStop = false;
|
||||||
this.groupBox1.Text = "Detail";
|
this.groupBox1.Text = "Detail";
|
||||||
@@ -155,13 +163,13 @@
|
|||||||
//
|
//
|
||||||
this.saveUsernameButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.saveUsernameButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.saveUsernameButton.Enabled = false;
|
this.saveUsernameButton.Enabled = false;
|
||||||
this.saveUsernameButton.Location = new System.Drawing.Point(444, 83);
|
this.saveUsernameButton.Location = new System.Drawing.Point(666, 99);
|
||||||
this.saveUsernameButton.Margin = new System.Windows.Forms.Padding(2);
|
|
||||||
this.saveUsernameButton.Name = "saveUsernameButton";
|
this.saveUsernameButton.Name = "saveUsernameButton";
|
||||||
this.saveUsernameButton.Size = new System.Drawing.Size(75, 23);
|
this.saveUsernameButton.Size = new System.Drawing.Size(112, 34);
|
||||||
this.saveUsernameButton.TabIndex = 4;
|
this.saveUsernameButton.TabIndex = 4;
|
||||||
this.saveUsernameButton.Text = "Save";
|
this.saveUsernameButton.Text = "Save";
|
||||||
this.saveUsernameButton.UseVisualStyleBackColor = true;
|
this.saveUsernameButton.UseVisualStyleBackColor = true;
|
||||||
|
this.saveUsernameButton.Click += new System.EventHandler(this.saveUsernameButton_Click);
|
||||||
//
|
//
|
||||||
// groupBox2
|
// groupBox2
|
||||||
//
|
//
|
||||||
@@ -173,11 +181,9 @@
|
|||||||
this.groupBox2.Controls.Add(this.label1);
|
this.groupBox2.Controls.Add(this.label1);
|
||||||
this.groupBox2.Controls.Add(this.PasswordAgainBox);
|
this.groupBox2.Controls.Add(this.PasswordAgainBox);
|
||||||
this.groupBox2.Controls.Add(this.NewPasswordBox);
|
this.groupBox2.Controls.Add(this.NewPasswordBox);
|
||||||
this.groupBox2.Location = new System.Drawing.Point(5, 135);
|
this.groupBox2.Location = new System.Drawing.Point(8, 202);
|
||||||
this.groupBox2.Margin = new System.Windows.Forms.Padding(2);
|
|
||||||
this.groupBox2.Name = "groupBox2";
|
this.groupBox2.Name = "groupBox2";
|
||||||
this.groupBox2.Padding = new System.Windows.Forms.Padding(2);
|
this.groupBox2.Size = new System.Drawing.Size(789, 212);
|
||||||
this.groupBox2.Size = new System.Drawing.Size(526, 158);
|
|
||||||
this.groupBox2.TabIndex = 8;
|
this.groupBox2.TabIndex = 8;
|
||||||
this.groupBox2.TabStop = false;
|
this.groupBox2.TabStop = false;
|
||||||
this.groupBox2.Text = "Change password";
|
this.groupBox2.Text = "Change password";
|
||||||
@@ -186,31 +192,29 @@
|
|||||||
//
|
//
|
||||||
this.SavePasswordButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.SavePasswordButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.SavePasswordButton.Enabled = false;
|
this.SavePasswordButton.Enabled = false;
|
||||||
this.SavePasswordButton.Location = new System.Drawing.Point(439, 124);
|
this.SavePasswordButton.Location = new System.Drawing.Point(658, 170);
|
||||||
this.SavePasswordButton.Margin = new System.Windows.Forms.Padding(2);
|
|
||||||
this.SavePasswordButton.Name = "SavePasswordButton";
|
this.SavePasswordButton.Name = "SavePasswordButton";
|
||||||
this.SavePasswordButton.Size = new System.Drawing.Size(75, 23);
|
this.SavePasswordButton.Size = new System.Drawing.Size(112, 34);
|
||||||
this.SavePasswordButton.TabIndex = 2;
|
this.SavePasswordButton.TabIndex = 2;
|
||||||
this.SavePasswordButton.Text = "Save";
|
this.SavePasswordButton.Text = "Save";
|
||||||
this.SavePasswordButton.UseVisualStyleBackColor = true;
|
this.SavePasswordButton.UseVisualStyleBackColor = true;
|
||||||
|
this.SavePasswordButton.Click += new System.EventHandler(this.SavePasswordButton_Click);
|
||||||
//
|
//
|
||||||
// label3
|
// label3
|
||||||
//
|
//
|
||||||
this.label3.AutoSize = true;
|
this.label3.AutoSize = true;
|
||||||
this.label3.Location = new System.Drawing.Point(14, 72);
|
this.label3.Location = new System.Drawing.Point(21, 108);
|
||||||
this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
|
||||||
this.label3.Name = "label3";
|
this.label3.Name = "label3";
|
||||||
this.label3.Size = new System.Drawing.Size(136, 15);
|
this.label3.Size = new System.Drawing.Size(207, 25);
|
||||||
this.label3.TabIndex = 3;
|
this.label3.TabIndex = 3;
|
||||||
this.label3.Text = "The new password again";
|
this.label3.Text = "The new password again";
|
||||||
//
|
//
|
||||||
// label1
|
// label1
|
||||||
//
|
//
|
||||||
this.label1.AutoSize = true;
|
this.label1.AutoSize = true;
|
||||||
this.label1.Location = new System.Drawing.Point(14, 24);
|
this.label1.Location = new System.Drawing.Point(21, 36);
|
||||||
this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
|
||||||
this.label1.Name = "label1";
|
this.label1.Name = "label1";
|
||||||
this.label1.Size = new System.Drawing.Size(84, 15);
|
this.label1.Size = new System.Drawing.Size(129, 25);
|
||||||
this.label1.TabIndex = 2;
|
this.label1.TabIndex = 2;
|
||||||
this.label1.Text = "New password";
|
this.label1.Text = "New password";
|
||||||
//
|
//
|
||||||
@@ -219,24 +223,24 @@
|
|||||||
this.PasswordAgainBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
this.PasswordAgainBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.PasswordAgainBox.Enabled = false;
|
this.PasswordAgainBox.Enabled = false;
|
||||||
this.PasswordAgainBox.Location = new System.Drawing.Point(14, 89);
|
this.PasswordAgainBox.Location = new System.Drawing.Point(21, 134);
|
||||||
this.PasswordAgainBox.Margin = new System.Windows.Forms.Padding(2);
|
|
||||||
this.PasswordAgainBox.Name = "PasswordAgainBox";
|
this.PasswordAgainBox.Name = "PasswordAgainBox";
|
||||||
this.PasswordAgainBox.Size = new System.Drawing.Size(500, 23);
|
this.PasswordAgainBox.Size = new System.Drawing.Size(748, 31);
|
||||||
this.PasswordAgainBox.TabIndex = 1;
|
this.PasswordAgainBox.TabIndex = 1;
|
||||||
this.PasswordAgainBox.UseSystemPasswordChar = true;
|
this.PasswordAgainBox.UseSystemPasswordChar = true;
|
||||||
|
this.PasswordAgainBox.TextChanged += new System.EventHandler(this.NewPasswordBox_TextChanged);
|
||||||
//
|
//
|
||||||
// NewPasswordBox
|
// NewPasswordBox
|
||||||
//
|
//
|
||||||
this.NewPasswordBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
this.NewPasswordBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.NewPasswordBox.Enabled = false;
|
this.NewPasswordBox.Enabled = false;
|
||||||
this.NewPasswordBox.Location = new System.Drawing.Point(14, 41);
|
this.NewPasswordBox.Location = new System.Drawing.Point(21, 62);
|
||||||
this.NewPasswordBox.Margin = new System.Windows.Forms.Padding(2);
|
|
||||||
this.NewPasswordBox.Name = "NewPasswordBox";
|
this.NewPasswordBox.Name = "NewPasswordBox";
|
||||||
this.NewPasswordBox.Size = new System.Drawing.Size(500, 23);
|
this.NewPasswordBox.Size = new System.Drawing.Size(748, 31);
|
||||||
this.NewPasswordBox.TabIndex = 0;
|
this.NewPasswordBox.TabIndex = 0;
|
||||||
this.NewPasswordBox.UseSystemPasswordChar = true;
|
this.NewPasswordBox.UseSystemPasswordChar = true;
|
||||||
|
this.NewPasswordBox.TextChanged += new System.EventHandler(this.NewPasswordBox_TextChanged);
|
||||||
//
|
//
|
||||||
// UsernameBox
|
// UsernameBox
|
||||||
//
|
//
|
||||||
@@ -244,34 +248,34 @@
|
|||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.UsernameBox.CausesValidation = false;
|
this.UsernameBox.CausesValidation = false;
|
||||||
this.UsernameBox.Enabled = false;
|
this.UsernameBox.Enabled = false;
|
||||||
this.UsernameBox.Location = new System.Drawing.Point(19, 44);
|
this.UsernameBox.Location = new System.Drawing.Point(28, 66);
|
||||||
this.UsernameBox.Margin = new System.Windows.Forms.Padding(2);
|
|
||||||
this.UsernameBox.Name = "UsernameBox";
|
this.UsernameBox.Name = "UsernameBox";
|
||||||
this.UsernameBox.Size = new System.Drawing.Size(500, 23);
|
this.UsernameBox.Size = new System.Drawing.Size(748, 31);
|
||||||
this.UsernameBox.TabIndex = 9;
|
this.UsernameBox.TabIndex = 9;
|
||||||
|
this.UsernameBox.TextChanged += new System.EventHandler(this.UsernameBox_TextChanged);
|
||||||
//
|
//
|
||||||
// label4
|
// label4
|
||||||
//
|
//
|
||||||
this.label4.AutoSize = true;
|
this.label4.AutoSize = true;
|
||||||
this.label4.Location = new System.Drawing.Point(19, 27);
|
this.label4.Location = new System.Drawing.Point(28, 40);
|
||||||
this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
|
||||||
this.label4.Name = "label4";
|
this.label4.Name = "label4";
|
||||||
this.label4.Size = new System.Drawing.Size(60, 15);
|
this.label4.Size = new System.Drawing.Size(91, 25);
|
||||||
this.label4.TabIndex = 10;
|
this.label4.TabIndex = 10;
|
||||||
this.label4.Text = "Username";
|
this.label4.Text = "Username";
|
||||||
//
|
//
|
||||||
// UserManagementForm
|
// UserManagementForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(144F, 144F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||||
this.BackColor = System.Drawing.SystemColors.Window;
|
this.BackColor = System.Drawing.SystemColors.Window;
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
this.ClientSize = new System.Drawing.Size(1191, 650);
|
||||||
this.Controls.Add(this.groupBox1);
|
this.Controls.Add(this.groupBox1);
|
||||||
this.Controls.Add(this.panel1);
|
this.Controls.Add(this.panel1);
|
||||||
this.Controls.Add(this.listView1);
|
this.Controls.Add(this.listView1);
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
this.MaximumSize = new System.Drawing.Size(816, 489);
|
this.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.MinimumSize = new System.Drawing.Size(816, 489);
|
this.MaximumSize = new System.Drawing.Size(1213, 706);
|
||||||
|
this.MinimumSize = new System.Drawing.Size(1213, 706);
|
||||||
this.Name = "UserManagementForm";
|
this.Name = "UserManagementForm";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||||
this.Text = "Management";
|
this.Text = "Management";
|
||||||
|
|||||||
@@ -158,5 +158,121 @@ namespace OpenSaveCloudClient
|
|||||||
SavePasswordButton.Enabled = v;
|
SavePasswordButton.Enabled = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void NewPasswordBox_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listView1.SelectedItems.Count == 1) {
|
||||||
|
bool valid = true;
|
||||||
|
if (string.IsNullOrEmpty(NewPasswordBox.Text) || string.IsNullOrEmpty(PasswordAgainBox.Text))
|
||||||
|
{
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
else if (NewPasswordBox.Text != PasswordAgainBox.Text)
|
||||||
|
{
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
SavePasswordButton.Enabled = valid;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SavePasswordButton.Enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SavePasswordButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listView1.SelectedItems.Count != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LockControls(true);
|
||||||
|
if (string.IsNullOrEmpty(NewPasswordBox.Text) || string.IsNullOrEmpty(PasswordAgainBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show(
|
||||||
|
"Password fields are empty",
|
||||||
|
"Change password",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
LockControls(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (NewPasswordBox.Text != PasswordAgainBox.Text)
|
||||||
|
{
|
||||||
|
MessageBox.Show(
|
||||||
|
"Passwords not matches",
|
||||||
|
"Change password",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
LockControls(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!PasswordTool.CheckRequirements(NewPasswordBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show(
|
||||||
|
"Passwords need at least 6 characters",
|
||||||
|
"Change password",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
LockControls(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long userId = Convert.ToInt64(listView1.SelectedItems[0].SubItems[1].Text);
|
||||||
|
ThreadPool.QueueUserWorkItem(delegate
|
||||||
|
{
|
||||||
|
serverConnector.ChangePassword(userId, new NewPassword { Password = NewPasswordBox.Text, VerifyPassword = PasswordAgainBox.Text });
|
||||||
|
this.Invoke((MethodInvoker)delegate {
|
||||||
|
NewPasswordBox.Clear();
|
||||||
|
PasswordAgainBox.Clear();
|
||||||
|
LockControls(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveUsernameButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LockControls(true);
|
||||||
|
if (UsernameBox.Text.Length < 3)
|
||||||
|
{
|
||||||
|
MessageBox.Show(
|
||||||
|
"Username need at least 3 characters",
|
||||||
|
"Change username",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
LockControls(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long userId = Convert.ToInt64(listView1.SelectedItems[0].SubItems[1].Text);
|
||||||
|
ThreadPool.QueueUserWorkItem(delegate
|
||||||
|
{
|
||||||
|
serverConnector.ChangeUsername(new UpdateUsername { Id = userId, Username = UsernameBox.Text });
|
||||||
|
this.Invoke((MethodInvoker)delegate {
|
||||||
|
listView1.SelectedItems[0].SubItems[0].Text = UsernameBox.Text;
|
||||||
|
LockControls(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UsernameBox_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listView1.SelectedItems.Count == 1)
|
||||||
|
{
|
||||||
|
string currentUsername = listView1.SelectedItems[0].SubItems[0].Text;
|
||||||
|
bool valid = true;
|
||||||
|
if (UsernameBox.Text.Length < 3)
|
||||||
|
{
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
else if (UsernameBox.Text == currentUsername)
|
||||||
|
{
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
saveUsernameButton.Enabled = valid;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
saveUsernameButton.Enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user