public static bool EnsureLoggedIn(UserSession userSession) { bool result = false; if (userSession != null && userSession.AwaitingAuthentication == false) { string userId = RestAPIWrapper.GetRealUserId(); if (string.IsNullOrEmpty(userId)) { userSession.Login(); result = RestAPIWrapper.GetRealUserId() != null; } else { result = true; } } return(result); }