// message processing protected JsonMessage ProcessAuthMessage(JsonMessage request, JsonMessageHost.SessionManager sessions) { if (request as SessionSecuredRequest != null) { string uid = GetSessionDataS((request as SessionSecuredRequest).SessionID, ValidLoginString); if (uid != (request as SessionSecuredRequest).UserID) // make sure they are the same person we think they are { Sessions.ClearSessionData((request as SessionSecuredRequest).SessionID); return(GeneralErrorMessage.SessionError); } } JsonMessage responce = null; if (request as CreateUserRequest != null) { responce = CreateUser(request as CreateUserRequest); } else if (request as LoginUserRequest != null) { responce = LoginUser(request as LoginUserRequest); } else if (request as ValidateEmailTokenRequest != null) { responce = ValidateEmailToken(request as ValidateEmailTokenRequest); } else if (request as ChangePasswordRequest != null) { responce = ChangePassword(request as ChangePasswordRequest); } else if (request as ValidateAuthenticationTokenRequest != null) { responce = ValidateAuthenticationToken(request as ValidateAuthenticationTokenRequest); } else if (request as PeerAddUserRequest != null) { responce = PeerAddUser(request as PeerAddUserRequest); } // ensure the session ID gets passed on if (responce as SessionSecuredResponce != null && request as SessionSecuredRequest != null) { (responce as SessionSecuredResponce).SessionID = (request as SessionSecuredRequest).SessionID; } return(responce); }
static JsonMessage HandleControllMessage(JsonMessage request, JsonMessageHost.SessionManager sessions) { if (!ValidateTokenRequest(request as TokenAuthenticatedRequest)) { return(null); } TokenAuthenticatedResponce responce = null; if (request as NodeStatusRequest != null) { responce = BuildNodeStatus(); } return(SignResponce(responce, request as TokenAuthenticatedRequest)); }