From 652fdabc3e22c4d41850f06496c3b7972b1c35a8 Mon Sep 17 00:00:00 2001 From: lukeIam Date: Wed, 16 Oct 2013 15:42:52 +0200 Subject: [PATCH] Allow users to change/set their password for the webserver --- ClientServerLib/ClientServerLib/CWebservice.cs | 15 ++++++++++++++- ClientServerLib/ClientServerLib/DataStructs.cs | 2 ++ Vocaluxe/Website/index.html | 4 ++++ Vocaluxe/Website/js/main.js | 6 +++++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ClientServerLib/ClientServerLib/CWebservice.cs b/ClientServerLib/ClientServerLib/CWebservice.cs index e6fa5f11..9e626de1 100644 --- a/ClientServerLib/ClientServerLib/CWebservice.cs +++ b/ClientServerLib/ClientServerLib/CWebservice.cs @@ -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) diff --git a/ClientServerLib/ClientServerLib/DataStructs.cs b/ClientServerLib/ClientServerLib/DataStructs.cs index 700f76fa..894c2a28 100644 --- a/ClientServerLib/ClientServerLib/DataStructs.cs +++ b/ClientServerLib/ClientServerLib/DataStructs.cs @@ -34,6 +34,8 @@ namespace ServerLib public int ProfileId; [DataMember] public bool IsEditable; + [DataMember] + public string Password; } #endregion diff --git a/Vocaluxe/Website/index.html b/Vocaluxe/Website/index.html index 2f456753..54ead8a1 100644 --- a/Vocaluxe/Website/index.html +++ b/Vocaluxe/Website/index.html @@ -130,6 +130,10 @@ + + + +
Save and upload diff --git a/Vocaluxe/Website/js/main.js b/Vocaluxe/Website/js/main.js index 740687a1..1df294ff 100644 --- a/Vocaluxe/Website/js/main.js +++ b/Vocaluxe/Website/js/main.js @@ -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('
'); $.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('
'); $.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(); } }