public Credentials GetCredentials()
        {
            FormsAuthenticationTicket ticket = formsAuthenticationService.GetUserTicket();

            if (ticket != null)
            {
                return(CredentialsProvider.ForSession(ticket.UserData).GetCredentials());
            }
            return(null);
        }
Esempio n. 2
0
        public ActionResult Logout()
        {
            var ticket = formsAuthenticationService.GetUserTicket();

            if (ticket != null)
            {
                string user = ticket.Name;
                amplaUserService.Logout(user);
                Information("Logout successful.");
            }
            amplaSessionStorage.SetAmplaSession(null);
            formsAuthenticationService.SignOut();
            return(RedirectToAction("Index", "Home"));
        }
 /// <summary>
 /// Make sure the Session is aligned.
 /// </summary>
 public void Execute()
 {
     if (httpRequest.IsAuthenticated)
     {
         if (amplaSessionStorage.Enabled)
         {
             string session = amplaSessionStorage.GetAmplaSession();
             if (string.IsNullOrEmpty(session))
             {
                 var ticket = formsAuthenticationService.GetUserTicket();
                 if (ticket != null)
                 {
                     string formsSession = ticket.UserData;
                     if (!string.IsNullOrEmpty(formsSession))
                     {
                         amplaSessionStorage.SetAmplaSession(formsSession);
                     }
                 }
             }
         }
     }
 }