From 6ae126ca421fe5712e1fb1ad643aff599d09c4c8 Mon Sep 17 00:00:00 2001
From: lukeIam <2lukeiam@gmail.com>
Date: Mon, 30 Apr 2018 13:38:29 +0200
Subject: [PATCH 1/3] Fix: App is broken as the client sends integers instead
of Guids (fixes #364)
---
Vocaluxe/Website/js/main.js | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/Vocaluxe/Website/js/main.js b/Vocaluxe/Website/js/main.js
index 3b9f96da..ea402e5c 100644
--- a/Vocaluxe/Website/js/main.js
+++ b/Vocaluxe/Website/js/main.js
@@ -192,8 +192,8 @@
var t = this;
this.customSelectPlaylistSongCallback = null;
- this.profileIdRequest = -1;
- this.songIdRequest = -1;
+ this.profileIdRequest = '00000000-0000-0000-0000-000000000000';
+ this.songIdRequest = '00000000-0000-0000-0000-000000000000';
this.init = function () {
replaceTransitionHandler();
@@ -207,8 +207,8 @@
this.reset = function () {
t.customSelectPlaylistSongCallback = null;
- t.profileIdRequest = -1;
- t.songIdRequest = -1;
+ t.profileIdRequest = '00000000-0000-0000-0000-000000000000';
+ t.songIdRequest = '00000000-0000-0000-0000-000000000000';
};
var replaceTransitionHandler = function () {
@@ -251,7 +251,7 @@
}
if (sessionHandler.sessionId != "") {
- if (sessionHandler.ownProfileId != -1) {
+ if (sessionHandler.ownProfileId != '00000000-0000-0000-0000-000000000000') {
$.mobile.changePage("#main", { transition: "slidefade" });
} else {
request({
@@ -297,8 +297,8 @@
});
$('#registerButton').click(function () {
- sessionHandler.ownProfileId = -1;
- pageHandler.profileIdRequest = -1;
+ sessionHandler.ownProfileId = '00000000-0000-0000-0000-000000000000';
+ pageHandler.profileIdRequest = '00000000-0000-0000-0000-000000000000';
$.mobile.changePage("#displayProfile", { transition: "slidefade" });
});
};
@@ -549,7 +549,7 @@
};
var pagebeforeshowDisplayProfile = function () {
- if (pageHandler.profileIdRequest >= 0) {
+ if (pageHandler.profileIdRequest != '00000000-0000-0000-0000-000000000000') {
var promise = request({
url: "getProfile?profileId=" + pageHandler.profileIdRequest
}).done(function (result) {
@@ -596,7 +596,7 @@
"Difficulty": 0,
"IsEditable": true,
"PlayerName": i18n.t("YourName") || "YourName",
- "ProfileId": -1,
+ "ProfileId": '00000000-0000-0000-0000-000000000000',
"Type": 1
});
$('#playerType').prop("value", 0);
@@ -605,7 +605,7 @@
$('#playerSaveButton').click(function () {
var dataToUpload = {};
- dataToUpload["ProfileId"] = -1;
+ dataToUpload["ProfileId"] = '00000000-0000-0000-0000-000000000000';
dataToUpload["PlayerName"] = $('#playerName').prop("value");
dataToUpload["Type"] = $('#playerType').prop("value");
dataToUpload["Difficulty"] = $('#playerDifficulty').prop("value");
@@ -738,7 +738,7 @@
$('#selectUserAdminList').children().remove();
function handleSelectUserAdminLineClick(e) {
- pageHandler.profileIdRequest = parseInt(e.currentTarget.id.replace("SelectUserAdminLine_", ""));
+ pageHandler.profileIdRequest = e.currentTarget.id.replace("SelectUserAdminLine_", "");
$.mobile.changePage("#displayUserAdmin", { transition: "slidefade" });
}
@@ -1190,7 +1190,7 @@
}
function SessionHandler() {
- this.ownProfileId = -1;
+ this.ownProfileId = '00000000-0000-0000-0000-000000000000';
this.sessionId = "";
this.serverBaseAddress = "";
@@ -1204,7 +1204,7 @@
request({
url: "logout"
}, "noOverlay").always(function () {
- t.ownProfileId = -1;
+ t.ownProfileId = '00000000-0000-0000-0000-000000000000';
t.sessionId = "";
@@ -1219,8 +1219,8 @@
var checkSession = function () {
- if (t.ownProfileId == -1
- && pageHandler.profileIdRequest == -1
+ if (t.ownProfileId == '00000000-0000-0000-0000-000000000000'
+ && pageHandler.profileIdRequest == '00000000-0000-0000-0000-000000000000'
&& ($.mobile.activePage.attr("id") == "displayProfile" || $.mobile.activePage.attr("id") == "login")) {
return;
}
From fdeaea7f406821d419a534e270f4fc5a0cd75881 Mon Sep 17 00:00:00 2001
From: lukeIam <2lukeiam@gmail.com>
Date: Mon, 30 Apr 2018 14:24:00 +0200
Subject: [PATCH 2/3] Introduce a constant for the empty guid in main.js
---
Vocaluxe/Website/js/main.js | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/Vocaluxe/Website/js/main.js b/Vocaluxe/Website/js/main.js
index ea402e5c..f64afd3d 100644
--- a/Vocaluxe/Website/js/main.js
+++ b/Vocaluxe/Website/js/main.js
@@ -1,6 +1,7 @@
///
///
(function () {
+ var PROFILE_NULL_ID = '00000000-0000-0000-0000-000000000000';
var imageLoader;
var translator;
var pageHandler;
@@ -192,8 +193,8 @@
var t = this;
this.customSelectPlaylistSongCallback = null;
- this.profileIdRequest = '00000000-0000-0000-0000-000000000000';
- this.songIdRequest = '00000000-0000-0000-0000-000000000000';
+ this.profileIdRequest = PROFILE_NULL_ID;
+ this.songIdRequest = PROFILE_NULL_ID;
this.init = function () {
replaceTransitionHandler();
@@ -207,8 +208,8 @@
this.reset = function () {
t.customSelectPlaylistSongCallback = null;
- t.profileIdRequest = '00000000-0000-0000-0000-000000000000';
- t.songIdRequest = '00000000-0000-0000-0000-000000000000';
+ t.profileIdRequest = PROFILE_NULL_ID;
+ t.songIdRequest = PROFILE_NULL_ID;
};
var replaceTransitionHandler = function () {
@@ -251,7 +252,7 @@
}
if (sessionHandler.sessionId != "") {
- if (sessionHandler.ownProfileId != '00000000-0000-0000-0000-000000000000') {
+ if (sessionHandler.ownProfileId != PROFILE_NULL_ID) {
$.mobile.changePage("#main", { transition: "slidefade" });
} else {
request({
@@ -297,8 +298,8 @@
});
$('#registerButton').click(function () {
- sessionHandler.ownProfileId = '00000000-0000-0000-0000-000000000000';
- pageHandler.profileIdRequest = '00000000-0000-0000-0000-000000000000';
+ sessionHandler.ownProfileId = PROFILE_NULL_ID;
+ pageHandler.profileIdRequest = PROFILE_NULL_ID;
$.mobile.changePage("#displayProfile", { transition: "slidefade" });
});
};
@@ -549,7 +550,7 @@
};
var pagebeforeshowDisplayProfile = function () {
- if (pageHandler.profileIdRequest != '00000000-0000-0000-0000-000000000000') {
+ if (pageHandler.profileIdRequest != PROFILE_NULL_ID) {
var promise = request({
url: "getProfile?profileId=" + pageHandler.profileIdRequest
}).done(function (result) {
@@ -596,7 +597,7 @@
"Difficulty": 0,
"IsEditable": true,
"PlayerName": i18n.t("YourName") || "YourName",
- "ProfileId": '00000000-0000-0000-0000-000000000000',
+ "ProfileId": PROFILE_NULL_ID,
"Type": 1
});
$('#playerType').prop("value", 0);
@@ -605,7 +606,7 @@
$('#playerSaveButton').click(function () {
var dataToUpload = {};
- dataToUpload["ProfileId"] = '00000000-0000-0000-0000-000000000000';
+ dataToUpload["ProfileId"] = PROFILE_NULL_ID;
dataToUpload["PlayerName"] = $('#playerName').prop("value");
dataToUpload["Type"] = $('#playerType').prop("value");
dataToUpload["Difficulty"] = $('#playerDifficulty').prop("value");
@@ -1190,7 +1191,7 @@
}
function SessionHandler() {
- this.ownProfileId = '00000000-0000-0000-0000-000000000000';
+ this.ownProfileId = PROFILE_NULL_ID;
this.sessionId = "";
this.serverBaseAddress = "";
@@ -1204,7 +1205,7 @@
request({
url: "logout"
}, "noOverlay").always(function () {
- t.ownProfileId = '00000000-0000-0000-0000-000000000000';
+ t.ownProfileId = PROFILE_NULL_ID;
t.sessionId = "";
@@ -1219,8 +1220,8 @@
var checkSession = function () {
- if (t.ownProfileId == '00000000-0000-0000-0000-000000000000'
- && pageHandler.profileIdRequest == '00000000-0000-0000-0000-000000000000'
+ if (t.ownProfileId == PROFILE_NULL_ID
+ && pageHandler.profileIdRequest == PROFILE_NULL_ID
&& ($.mobile.activePage.attr("id") == "displayProfile" || $.mobile.activePage.attr("id") == "login")) {
return;
}
From 9894685f28550fa13f5b81fbd746fbca03b9e513 Mon Sep 17 00:00:00 2001
From: lukeIam <2lukeiam@gmail.com>
Date: Mon, 30 Apr 2018 14:24:42 +0200
Subject: [PATCH 3/3] Prevent profiles with GUID.Empty as ID
---
Vocaluxe/Base/CProfiles.cs | 2 +-
Vocaluxe/Base/Server/CWebservice.cs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Vocaluxe/Base/CProfiles.cs b/Vocaluxe/Base/CProfiles.cs
index 12440e5f..04354a5f 100644
--- a/Vocaluxe/Base/CProfiles.cs
+++ b/Vocaluxe/Base/CProfiles.cs
@@ -357,7 +357,7 @@ namespace Vocaluxe.Base
public static bool IsProfileIDValid(Guid profileID)
{
- return _Profiles.ContainsKey(profileID);
+ return profileID != Guid.Empty && _Profiles.ContainsKey(profileID);
}
public static bool IsAvatarIDValid(int avatarID)
diff --git a/Vocaluxe/Base/Server/CWebservice.cs b/Vocaluxe/Base/Server/CWebservice.cs
index e44606a1..e2315c80 100644
--- a/Vocaluxe/Base/Server/CWebservice.cs
+++ b/Vocaluxe/Base/Server/CWebservice.cs
@@ -90,7 +90,7 @@ namespace Vocaluxe.Base.Server
{
Guid sessionKey = _GetSession();
- if (profile.ProfileId != Guid.Empty) //-1 is the id for a new profile
+ if (profile.ProfileId != Guid.Empty) //Guid.Empty is the id for a new profile
{
if (CSessionControl.GetUserIdFromSession(sessionKey) != profile.ProfileId
&& !(_CheckRight(EUserRights.EditAllProfiles)))