Esempio n. 1
0
        public ActionResult LoginIntegrated(string returnUrl)
        {
            IntegratedLoginModel model = new IntegratedLoginModel {
                UseIntegratedSecurity = true
            };

            if (ModelState.IsValid)
            {
                string message;
                if (!model.UseIntegratedSecurity)
                {
                    return(RedirectToAction("Login"));
                }

                AmplaUser amplaUser = amplaUserService.IntegratedLogin(out message);
                if (amplaUser != null)
                {
                    amplaSessionStorage.SetAmplaSession(amplaUser.Session);
                    formsAuthenticationService.StoreUserTicket(amplaUser, model.RememberMe);

                    if (UrlIsLocal(returnUrl))
                    {
                        Information("Login successful.");
                        return(Redirect(returnUrl));
                    }
                    return(RedirectToAction("Index", "Home"));
                }
                Error(message);
                ModelState.AddModelError("", message);
            }

            // If we got this far, something failed, redisplay form
            return(View("Login"));
        }
Esempio n. 2
0
        /// <summary>
        /// Login the session if possible
        /// </summary>
        public void Execute()
        {
            NameValueCollection queryString = requestWrapper.QueryString;

            string amplaSession = queryString["amplaSession"];

            if (!string.IsNullOrEmpty(amplaSession))
            {
                if (amplaUserService != null)
                {
                    string    message;
                    AmplaUser amplaUser = amplaUserService.SessionLogin(amplaSession, out message);
                    if (amplaUser != null)
                    {
                        formsAuthenticationService.StoreUserTicket(amplaUser, false);
                        amplaSessionStorage.SetAmplaSession(amplaUser.Session);

                        UriBuilder builder = new UriBuilder(requestWrapper.Url);
                        var        query   = HttpUtility.ParseQueryString(builder.Query);
                        query.Remove("amplaSession");
                        builder.Query = query.ToString();
                        responseWrapper.Redirect(builder.ToString());
                    }
                }
            }
        }
 /// <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);
                     }
                 }
             }
         }
     }
 }