/// <summary>
 /// Gets the credentials for the user
 /// </summary>
 /// <returns></returns>
 public Credentials GetCredentials()
 {
     if (amplaSessionStorage.Enabled)
     {
         string session = amplaSessionStorage.GetAmplaSession();
         if (!string.IsNullOrEmpty(session))
         {
             return(CredentialsProvider.ForSession(session).GetCredentials());
         }
     }
     return(null);
 }
예제 #2
0
        protected override void Adapt()
        {
            string session = sessionStorage.GetAmplaSession();

            if (!string.IsNullOrEmpty(session))
            {
                if (userService.RenewSession(session) == null)
                {
                    formsAuthenticationService.SessionExpired();
                }
            }
        }
 /// <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);
                     }
                 }
             }
         }
     }
 }
예제 #4
0
        public ActionResult CurrentUser()
        {
            string session = amplaSessionStorage.GetAmplaSession();

            AmplaUser user = amplaUserService.RenewSession(session);

            if (user == null)
            {
                return(RedirectToAction("Login"));
            }

            UserModel model = new UserModel
            {
                UserName     = user.UserName,
                Session      = user.Session,
                Started      = user.LoginTime,
                LastActivity = user.LastActivity,
                LoginType    = user.LoginType
            };

            return(View("CurrentUser", model));
        }