Allow users to change/set their password for the webserver

This commit is contained in:
lukeIam committed 2013-12-13 17:43:16 +01:00
1 parent eca41bab2f
commit 652fdabc3e
4 files changed
+25 -2

No files matched your search

+14 -1
View File
@@ -197,7 +197,20 @@ namespace ServerLib
return false; 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) public ProfileData getProfile(int profileId)
@@ -34,6 +34,8 @@ namespace ServerLib
public int ProfileId; public int ProfileId;
[DataMember] [DataMember]
public bool IsEditable; public bool IsEditable;
[DataMember]
public string Password;
} }
#endregion #endregion
+4
View File
@@ -130,6 +130,10 @@
<option value="1">Normal</option> <option value="1">Normal</option>
<option value="2">Hard</option> <option value="2">Hard</option>
</select> </select>
<label for="playerPassword" class="input">New Password:</label>
<input type="password" id="playerPassword" name="playerPassword" data-mini="true" value="**oldPassword**">
<br /> <br />
<a data-role="button" id="playerSaveButton">Save and upload</a> <a data-role="button" id="playerSaveButton">Save and upload</a>
</div> </div>
+5 -1
View File
@@ -53,12 +53,13 @@ function initPageLoadHandler() {
dataToUpload["Type"] = $('#playerType').prop("value"); dataToUpload["Type"] = $('#playerType').prop("value");
dataToUpload["Difficulty"] = $('#playerDifficulty').prop("value"); dataToUpload["Difficulty"] = $('#playerDifficulty').prop("value");
dataToUpload["Avatar"] = $('#playerAvatar').data("changed") ? { "base64Data": $('#playerAvatar').prop("src") } : null; 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" />'); $('#content').wrap('<div class="overlay" />');
$.mobile.loading('show', { $.mobile.loading('show', {
text: 'Uploading profile...', text: 'Uploading profile...',
textVisible: true textVisible: true
}); });
$.ajax({ $.ajax({
url: "sendProfile", url: "sendProfile",
@@ -102,6 +103,7 @@ function initPageLoadHandler() {
dataToUpload["Type"] = $('#playerType').prop("value"); dataToUpload["Type"] = $('#playerType').prop("value");
dataToUpload["Difficulty"] = $('#playerDifficulty').prop("value"); dataToUpload["Difficulty"] = $('#playerDifficulty').prop("value");
dataToUpload["Avatar"] = $('#playerAvatar').data("changed") ? { "base64Data": $('#playerAvatar').prop("src") } : null; 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" />'); $('#content').wrap('<div class="overlay" />');
$.mobile.loading('show', { $.mobile.loading('show', {
@@ -145,6 +147,7 @@ function initPageLoadHandler() {
$('#playerDifficulty').prop('disabled', false); $('#playerDifficulty').prop('disabled', false);
$('#playerSaveButton').show().unbind("click"); $('#playerSaveButton').show().unbind("click");
$('#playerAvatar').unbind("click"); $('#playerAvatar').unbind("click");
$('#playerPassword').prop('disabled', false).show();
$('#playerAvatar').click(function () { $('#playerAvatar').click(function () {
if ($('#captureContainer').length > 0) { if ($('#captureContainer').length > 0) {
@@ -175,6 +178,7 @@ function initPageLoadHandler() {
$('#playerDifficulty').prop('disabled', true); $('#playerDifficulty').prop('disabled', true);
$('#playerSaveButton').hide().unbind("click"); $('#playerSaveButton').hide().unbind("click");
$('#playerAvatar').unbind("click"); $('#playerAvatar').unbind("click");
$('#playerPassword').prop('disabled', true).hide();
} }
} }