diff --git a/ClientServerLib/ClientServerLib/CWebservice.cs b/ClientServerLib/ClientServerLib/CWebservice.cs
index 272fc025..34f493da 100644
--- a/ClientServerLib/ClientServerLib/CWebservice.cs
+++ b/ClientServerLib/ClientServerLib/CWebservice.cs
@@ -17,7 +17,7 @@ namespace ServerLib
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/sendKeyEvent?key={key}")]
- bool sendKeyEvent(string key);
+ void sendKeyEvent(string key);
#region profile
@@ -31,7 +31,7 @@ namespace ServerLib
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/sendProfile")]
- bool sendProfile(ProfileData profile);
+ void sendProfile(ProfileData profile);
[OperationContract]
[WebInvoke(Method = "GET",
@@ -54,7 +54,7 @@ namespace ServerLib
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/sendPhoto")]
- bool sendPhoto(PhotoData photo);
+ void sendPhoto(PhotoData photo);
#endregion
@@ -168,21 +168,30 @@ namespace ServerLib
return sessionKey;
}
- public bool sendKeyEvent(string key)
+ public void sendKeyEvent(string key)
{
Guid sessionKey = getSession();
- if (sessionKey == Guid.Empty || !SessionControl.requestRight(sessionKey, UserRights.UseKeyboard))
+ if (sessionKey == Guid.Empty )
{
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden;
- return false;
- }
+ WebOperationContext.Current.OutgoingResponse.StatusDescription = "No session";
- if (CServer.SendKeyEvent == null)
- {
- return false;
}
- return CServer.SendKeyEvent(key);
+ else if (!SessionControl.requestRight(sessionKey, UserRights.UseKeyboard))
+ {
+ WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden;
+ WebOperationContext.Current.OutgoingResponse.StatusDescription = "Not allowed";
+ }
+ else if (CServer.SendKeyEvent == null)
+ {
+ WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.NotFound;
+ WebOperationContext.Current.OutgoingResponse.StatusDescription = "Not found";
+ }
+ else
+ {
+ CServer.SendKeyEvent(key);
+ }
}
#region profile
@@ -193,35 +202,51 @@ namespace ServerLib
if (sessionKey == Guid.Empty)
{
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden;
+ WebOperationContext.Current.OutgoingResponse.StatusDescription = "No session";
return -1;
}
-
- return SessionControl.getUserIdFromSession(sessionKey);
+ int profileId = SessionControl.getUserIdFromSession(sessionKey);
+ if (profileId < 0)
+ {
+ WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden;
+ WebOperationContext.Current.OutgoingResponse.StatusDescription = "No session";
+ return -1;
+ }
+ return profileId;
}
- public bool sendProfile(ProfileData profile)
+ public void sendProfile(ProfileData profile)
{
Guid sessionKey = getSession();
if (profile.ProfileId != -1) //-1 is the id for a new profile
{
- if (sessionKey == Guid.Empty || (!SessionControl.requestRight(sessionKey, UserRights.EditAllProfiles) &&
- SessionControl.getUserIdFromSession(sessionKey) != profile.ProfileId))
+ if (sessionKey == Guid.Empty)
{
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden;
- return false;
+ WebOperationContext.Current.OutgoingResponse.StatusDescription = "No session";
+ return;
+ }
+
+ if (!SessionControl.requestRight(sessionKey, UserRights.EditAllProfiles) &&
+ SessionControl.getUserIdFromSession(sessionKey) != profile.ProfileId)
+ {
+ WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden;
+ WebOperationContext.Current.OutgoingResponse.StatusDescription = "Not allowed";
+ return;
}
}
if (CServer.SendProfileData == null)
{
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.NotFound;
- return false;
+ WebOperationContext.Current.OutgoingResponse.StatusDescription = "Not found";
+ return;
}
- bool result = CServer.SendProfileData(profile);
+ CServer.SendProfileData(profile);
- if (profile.Password != null && profile.Password != "")
+ if (!string.IsNullOrEmpty(profile.Password))
{
int profileId = profile.ProfileId;
if (profileId == -1)
@@ -231,18 +256,24 @@ namespace ServerLib
CServer.SetPassword(profileId, profile.Password);
}
-
- return result;
}
public ProfileData getProfile(int profileId)
{
Guid sessionKey = getSession();
- if (sessionKey == Guid.Empty || (!SessionControl.requestRight(sessionKey, UserRights.ViewOtherProfiles) &&
- SessionControl.getUserIdFromSession(sessionKey) != profileId))
+ if (sessionKey == Guid.Empty)
{
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden;
+ WebOperationContext.Current.OutgoingResponse.StatusDescription = "No session";
+ return new ProfileData();
+ }
+
+ if (!SessionControl.requestRight(sessionKey, UserRights.ViewOtherProfiles) &&
+ SessionControl.getUserIdFromSession(sessionKey) != profileId)
+ {
+ WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden;
+ WebOperationContext.Current.OutgoingResponse.StatusDescription = "Not allowed";
return new ProfileData();
}
@@ -270,16 +301,24 @@ namespace ServerLib
#region photo
- public bool sendPhoto(PhotoData photo)
+ public void sendPhoto(PhotoData photo)
{
Guid sessionKey = getSession();
+ if (sessionKey == Guid.Empty)
+ {
+ WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden;
+ WebOperationContext.Current.OutgoingResponse.StatusDescription = "No session";
+ return;
+ }
+
if (!SessionControl.requestRight(sessionKey, UserRights.UploadPhotos))
{
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden;
- return false;
+ WebOperationContext.Current.OutgoingResponse.StatusDescription = "Not allowed";
+ return;
}
- return CServer.SendPhoto(photo);
+ CServer.SendPhoto(photo);
}
#endregion
@@ -292,6 +331,7 @@ namespace ServerLib
if (sessionId == Guid.Empty)
{
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden;
+ WebOperationContext.Current.OutgoingResponse.StatusDescription = "Wrong username or password";
}
return sessionId;
}
@@ -424,9 +464,16 @@ namespace ServerLib
public void setUserRole(int profileId, int userRole)
{
Guid sessionKey = getSession();
+ if (sessionKey == Guid.Empty)
+ {
+ WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden;
+ WebOperationContext.Current.OutgoingResponse.StatusDescription = "No session";
+ return;
+ }
if (!SessionControl.requestRight(sessionKey, UserRights.EditAllProfiles))
{
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden;
+ WebOperationContext.Current.OutgoingResponse.StatusDescription = "Not allowed";
return;
}
CServer.SetUserRole(profileId, userRole);
diff --git a/ClientServerLib/ClientServerLib/SessionControl.cs b/ClientServerLib/ClientServerLib/SessionControl.cs
index ae9edf8e..c042803f 100644
--- a/ClientServerLib/ClientServerLib/SessionControl.cs
+++ b/ClientServerLib/ClientServerLib/SessionControl.cs
@@ -59,6 +59,10 @@ namespace ServerLib
internal static int getUserIdFromSession(Guid sessionId)
{
+ if (!activeSessions.ContainsKey(sessionId))
+ {
+ return -1;
+ }
return activeSessions[sessionId].ProfileId;
}
}
diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj
index 0ce49fa2..6ac3e6c1 100644
--- a/Vocaluxe/Vocaluxe.csproj
+++ b/Vocaluxe/Vocaluxe.csproj
@@ -312,6 +312,9 @@
PreserveNewest
images
+
+ PreserveNewest
+
PreserveNewest
images
diff --git a/Vocaluxe/Website/css/images/alert.png b/Vocaluxe/Website/css/images/alert.png
new file mode 100644
index 00000000..dd0e2afc
Binary files /dev/null and b/Vocaluxe/Website/css/images/alert.png differ
diff --git a/Vocaluxe/Website/css/style.css b/Vocaluxe/Website/css/style.css
index 7554a30d..f568b912 100644
--- a/Vocaluxe/Website/css/style.css
+++ b/Vocaluxe/Website/css/style.css
@@ -73,3 +73,10 @@
.ui-input-search {
background: #ffffff !important;
}
+
+.ui-custom-errorIcon {
+ background: url(images/alert.png) !important;
+ background-size: 42px 42px;
+ -webkit-border-radius: 0px !important;
+ border-radius: 0px !important;
+}
diff --git a/Vocaluxe/Website/js/main.js b/Vocaluxe/Website/js/main.js
index 1714fc17..a43136bf 100644
--- a/Vocaluxe/Website/js/main.js
+++ b/Vocaluxe/Website/js/main.js
@@ -598,7 +598,17 @@ function request(data, message) {
$('div[data-role="content"]').unwrap();
}
}).fail(function (result) {
- //TODO:Fail Handling
+ if (result.statusText.indexOf("No session") != -1) {
+ logout();
+ return;
+ }
+ if (message != "noOverlay") {
+ var msg = result.statusText.length <= 20 ? result.statusText : "Error...";
+ if (msg == "error" && result.readyState == 0) {
+ msg = "No connection";
+ }
+ showError(msg);
+ }
});
}
@@ -606,4 +616,17 @@ function showError(message) {
if (!message) {
message = "Error...";
}
+
+ $('div[data-role="content"]').wrap('');
+ $.mobile.loading('show', {
+ text: message,
+ textVisible: true
+ });
+ $('.ui-loader').find('span').removeClass('ui-icon-loading').addClass('ui-custom-errorIcon');
+
+ setTimeout(function() {
+ $.mobile.loading('hide');
+ $('div[data-role="content"]').unwrap();
+ $('.ui-loader').find('span').removeClass('ui-custom-errorIcon').addClass('ui-icon-loading');
+ }, 1000);
}
\ No newline at end of file