Ejemplo n.º 1
0
        public void LogoutUser(string fromToken, bool performRedirectToLoginPage = true)
        {
            var user = new FomMonitoringCore.SqlServer.Users();

            //Esce dalla forms authentication
            try
            {
                user = SessionsVariables.GetLoggedUser();

                //Esce dalla forms authentication
                FormsAuthentication.SignOut();
                if (user?.Username != null)
                {
                    InsertLogAuditRecord(true, user.Username, user, "Logout done succesfully");
                }
            }
            catch (Exception ex)
            {
                if (user?.Username != null)
                {
                    InsertLogAuditRecord(true, user.Username, user, "Logout error");
                }
            }

            //Rimuove eventualmente il coockie
            HttpContext.Current.Request.Cookies.Remove(FormsAuthentication.FormsCookieName);

            //Pulisce la sessione
            SessionsVariables.ClearSession();

            //Gestione Redirect
            //ExtensionMethods.CheckQueryStringAndRedirect(FromToken);
            if (performRedirectToLoginPage)
            {
                FormsAuthentication.RedirectToLoginPage(fromToken);
            }
        }
Ejemplo n.º 2
0
        public FomMonitoringCore.SqlServer.Users GetLoggedUser()
        {
            var user = SessionsVariables.GetLoggedUser();

            return(user);
        }