[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;
|
return sessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Logout()
|
||||||
|
{
|
||||||
|
Guid sessionKey = _GetSession();
|
||||||
|
CSessionControl.InvalidateSessions(sessionKey);
|
||||||
|
}
|
||||||
|
|
||||||
public Stream Index()
|
public Stream Index()
|
||||||
{
|
{
|
||||||
if (WebOperationContext.Current != null)
|
if (WebOperationContext.Current != null)
|
||||||
|
|||||||
@@ -71,6 +71,11 @@ namespace ServerLib
|
|||||||
UriTemplate = "/login?username={username}&password={password}")]
|
UriTemplate = "/login?username={username}&password={password}")]
|
||||||
Guid Login(string username, string password);
|
Guid Login(string username, string password);
|
||||||
|
|
||||||
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
|
UriTemplate = "/logout")]
|
||||||
|
void Logout();
|
||||||
|
|
||||||
[OperationContract, WebInvoke(Method = "GET",
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "")]
|
UriTemplate = "")]
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace ServerLib
|
|||||||
int id = _GetProfileIdFormUsername(userName);
|
int id = _GetProfileIdFormUsername(userName);
|
||||||
EUserRoles roles = _GetUserRoles(id);
|
EUserRoles roles = _GetUserRoles(id);
|
||||||
CSession session = new CSession(newId, id, roles);
|
CSession session = new CSession(newId, id, roles);
|
||||||
InvalidateSessions(id);
|
//InvalidateSessions(id);
|
||||||
_ActiveSessions.Add(newId, session);
|
_ActiveSessions.Add(newId, session);
|
||||||
|
|
||||||
return newId;
|
return newId;
|
||||||
@@ -63,6 +63,14 @@ namespace ServerLib
|
|||||||
_ActiveSessions.Remove(s.Key);
|
_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)
|
internal static bool RequestRight(Guid sessionId, EUserRights requestedRight)
|
||||||
{
|
{
|
||||||
return ((CUserRoleControl.GetUserRightsFromUserRole(_ActiveSessions[sessionId].Roles)
|
return ((CUserRoleControl.GetUserRightsFromUserRole(_ActiveSessions[sessionId].Roles)
|
||||||
|
|||||||
@@ -1412,16 +1412,20 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.logout = function () {
|
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) {
|
if (window.localStorage) {
|
||||||
window.localStorage.setItem("VocaluxeSessionKey", "");
|
window.localStorage.setItem("VocaluxeSessionKey", "");
|
||||||
}
|
}
|
||||||
$.mobile.changePage("#login", { transition: "slidefade" });
|
$.mobile.changePage("#login", { transition: "slidefade" });
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user