private MobileLoginInfoEndpoint ValidateRequestLogin(AppInfo appInfo, HeContext context, bool ignoreCSRFToken)
        {
            MobileLoginInfoEndpoint loginEndpoint = new MobileLoginInfoEndpoint(appInfo, appInfo.GetMobileLoginConfigurations());

            try {
                var login = loginEndpoint.ReadLoginInfoFromRequest();
                login.Validate(ignoreCSRFToken);
                loginEndpoint.Login(login, context.Session);
            } catch (InvalidLoginException ex) {
                throw new ExposeRestException("Invalid Login", HttpStatusCode.Forbidden, ex);
            }
            return(loginEndpoint);
        }
        /// <summary>
        ///     Gets User information of the authenticated user for a Mobile Application
        ///     This method is designed for interoperability scenarios where you need to embed a Responsive screen in your mobile application
        /// </summary>
        /// <param name="userId">Returns the user identifier, or NullIdentifier() (userId = 0) if user is not logged in</param>
        /// <param name="isPersistent">True if the login is persistent</param>
        public static void GetMobileAppLoginInfo(out int userId, out bool isPersistent)
        {
            var appInfo = AppInfo.GetAppInfo();

            var loginEndpoint = new MobileLoginInfoEndpoint(appInfo, appInfo.GetMobileLoginConfigurations());
            var loginInfo     = loginEndpoint.ReadLoginInfoFromRequest();

            loginInfo.Validate();
            loginInfo.Refresh();

            userId       = loginInfo.UserId;
            isPersistent = loginInfo.IsPersistent;
        }