Allow users to change/set their password for the webserver
This commit is contained in:
1 parent
eca41bab2f
commit
652fdabc3e
4 files changed
+25
-2
No files matched your search
@@ -197,7 +197,20 @@ namespace ServerLib
|
||||
return false;
|
||||
}
|
||||
|
||||
return CServer.SendProfileData(profile);
|
||||
bool result = CServer.SendProfileData(profile);
|
||||
|
||||
if (profile.Password != null && profile.Password != "")
|
||||
{
|
||||
int profileId = profile.ProfileId;
|
||||
if (profileId == -1)
|
||||
{
|
||||
profileId = CServer.GetUserIdFromUsername(profile.PlayerName);
|
||||
}
|
||||
|
||||
CServer.SetPassword(profileId, profile.Password);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public ProfileData getProfile(int profileId)
|
||||
|
||||
@@ -34,6 +34,8 @@ namespace ServerLib
|
||||
public int ProfileId;
|
||||
[DataMember]
|
||||
public bool IsEditable;
|
||||
[DataMember]
|
||||
public string Password;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -130,6 +130,10 @@
|
||||
<option value="1">Normal</option>
|
||||
<option value="2">Hard</option>
|
||||
</select>
|
||||
|
||||
<label for="playerPassword" class="input">New Password:</label>
|
||||
<input type="password" id="playerPassword" name="playerPassword" data-mini="true" value="**oldPassword**">
|
||||
|
||||
<br />
|
||||
<a data-role="button" id="playerSaveButton">Save and upload</a>
|
||||
</div>
|
||||
|
||||
@@ -53,12 +53,13 @@ function initPageLoadHandler() {
|
||||
dataToUpload["Type"] = $('#playerType').prop("value");
|
||||
dataToUpload["Difficulty"] = $('#playerDifficulty').prop("value");
|
||||
dataToUpload["Avatar"] = $('#playerAvatar').data("changed") ? { "base64Data": $('#playerAvatar').prop("src") } : null;
|
||||
dataToUpload["Password"] = $('#playerPassword').prop("value") != "**oldPassword**" ? $('#playerPassword').prop("value") : null;
|
||||
|
||||
$('#content').wrap('<div class="overlay" />');
|
||||
$.mobile.loading('show', {
|
||||
text: 'Uploading profile...',
|
||||
textVisible: true
|
||||
});
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: "sendProfile",
|
||||
@@ -102,6 +103,7 @@ function initPageLoadHandler() {
|
||||
dataToUpload["Type"] = $('#playerType').prop("value");
|
||||
dataToUpload["Difficulty"] = $('#playerDifficulty').prop("value");
|
||||
dataToUpload["Avatar"] = $('#playerAvatar').data("changed") ? { "base64Data": $('#playerAvatar').prop("src") } : null;
|
||||
dataToUpload["Password"] = $('#playerPassword').prop("value") != "**oldPassword**" ? $('#playerPassword').prop("value") : null;
|
||||
|
||||
$('#content').wrap('<div class="overlay" />');
|
||||
$.mobile.loading('show', {
|
||||
@@ -145,6 +147,7 @@ function initPageLoadHandler() {
|
||||
$('#playerDifficulty').prop('disabled', false);
|
||||
$('#playerSaveButton').show().unbind("click");
|
||||
$('#playerAvatar').unbind("click");
|
||||
$('#playerPassword').prop('disabled', false).show();
|
||||
|
||||
$('#playerAvatar').click(function () {
|
||||
if ($('#captureContainer').length > 0) {
|
||||
@@ -175,6 +178,7 @@ function initPageLoadHandler() {
|
||||
$('#playerDifficulty').prop('disabled', true);
|
||||
$('#playerSaveButton').hide().unbind("click");
|
||||
$('#playerAvatar').unbind("click");
|
||||
$('#playerPassword').prop('disabled', true).hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user