[Server] Allow multiple sessions with one user
This commit is contained in:
1 parent
51dc4391bd
commit
f4583b830a
4 files changed
+31
-8
No files matched your search
@@ -173,6 +173,12 @@ namespace ServerLib
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public void Logout()
|
||||
{
|
||||
Guid sessionKey = _GetSession();
|
||||
CSessionControl.InvalidateSessions(sessionKey);
|
||||
}
|
||||
|
||||
public Stream Index()
|
||||
{
|
||||
if (WebOperationContext.Current != null)
|
||||
|
||||
@@ -71,6 +71,11 @@ namespace ServerLib
|
||||
UriTemplate = "/login?username={username}&password={password}")]
|
||||
Guid Login(string username, string password);
|
||||
|
||||
[OperationContract, WebInvoke(Method = "GET",
|
||||
ResponseFormat = WebMessageFormat.Json,
|
||||
UriTemplate = "/logout")]
|
||||
void Logout();
|
||||
|
||||
[OperationContract, WebInvoke(Method = "GET",
|
||||
ResponseFormat = WebMessageFormat.Json,
|
||||
UriTemplate = "")]
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace ServerLib
|
||||
int id = _GetProfileIdFormUsername(userName);
|
||||
EUserRoles roles = _GetUserRoles(id);
|
||||
CSession session = new CSession(newId, id, roles);
|
||||
InvalidateSessions(id);
|
||||
//InvalidateSessions(id);
|
||||
_ActiveSessions.Add(newId, session);
|
||||
|
||||
return newId;
|
||||
@@ -63,6 +63,14 @@ namespace ServerLib
|
||||
_ActiveSessions.Remove(s.Key);
|
||||
}
|
||||
|
||||
internal static void InvalidateSessions(Guid sessionId)
|
||||
{
|
||||
if (_ActiveSessions.ContainsKey(sessionId))
|
||||
{
|
||||
_ActiveSessions.Remove(sessionId);
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool RequestRight(Guid sessionId, EUserRights requestedRight)
|
||||
{
|
||||
return ((CUserRoleControl.GetUserRightsFromUserRole(_ActiveSessions[sessionId].Roles)
|
||||
|
||||
@@ -1412,16 +1412,20 @@
|
||||
};
|
||||
|
||||
this.logout = function () {
|
||||
t.ownProfileId = -1;
|
||||
request({
|
||||
url: "logout"
|
||||
}, "noOverlay").always(function () {
|
||||
t.ownProfileId = -1;
|
||||
|
||||
t.sessionId = "";
|
||||
t.sessionId = "";
|
||||
|
||||
pageHandler.reset();
|
||||
pageHandler.reset();
|
||||
|
||||
if (window.localStorage) {
|
||||
window.localStorage.setItem("VocaluxeSessionKey", "");
|
||||
}
|
||||
$.mobile.changePage("#login", { transition: "slidefade" });
|
||||
if (window.localStorage) {
|
||||
window.localStorage.setItem("VocaluxeSessionKey", "");
|
||||
}
|
||||
$.mobile.changePage("#login", { transition: "slidefade" });
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user