public JsonResult GetAuthenticationToken(string SessionGuid) { try { var selectedSession = DbHelpers.GetSessionByGuid(SessionGuid); if (selectedSession != null) { var response = new AuthenticationToken { IsAuthenticated = selectedSession.IsValid, Message = "Success", Role = Roles.GetRolesForUser(selectedSession.UserName).Equals("Administrator") ? SmartVitals.Services.Enums.Roles.Administrator.ToString() : SmartVitals.Services.Enums.Roles.User.ToString(), Profile = UserInfo.GetFromProfile(WebProfile.GetProfile(selectedSession.UserName, selectedSession.IsValid)), SessionId = selectedSession.IsValid ? new Guid(SessionGuid) : new Guid() }; return(Json( new JsonResponse <AuthenticationToken> { Response = response, Success = true }, JsonRequestBehavior.AllowGet )); } return(Json( new JsonResponse <AuthenticationToken> { Response = null, Success = true, Message = "Expired or invalid session." }, JsonRequestBehavior.AllowGet )); } catch (Exception) { return(Json( new JsonResponse <AuthenticationToken> { Response = null, Success = false, Message = "An error occured while processing your request." }, JsonRequestBehavior.AllowGet )); } }