Пример #1
0
        public ActionResult Login(LogonViewModel model)
        {
            var result = UserService.Authenticate(model.Email, model.Password);

            if (result.IsAuthenticated)
            {
                Response.SetUserPermissions(result.User.UserRoles.SelectMany(r => r.WebPermissions).Select(wp => wp.Name));
                Response.SetAuth(result.User.Email);

                return RedirectToAction("Index", "Home");
            }
            else
            {
                return RedirectToAction("Logon", "Account", new LogonViewModel { Email = model.Email, Message = result.Message });
            }
        }
Пример #2
0
        public ActionResult Login(LogonViewModel model)
        {
            var result = UserService.Authenticate(model.Email, model.Password);

            if (result.IsAuthenticated)
            {
                var rolesCookie = new HttpCookie("roles") { Value = string.Join(",", result.User.UserRoles.Select(r => r.Code)), Expires = DateTime.Now.AddDays(30) };
                var authCookie = new HttpCookie("auth") { Value = result.User.Email, Expires = DateTime.Now.AddDays(30) };
                Response.Cookies.Set(rolesCookie);
                Response.Cookies.Set(authCookie);

                return RedirectToAction("Index", "Home");
            }
            else
            {
                return RedirectToAction("Logon", "Account",  new LogonViewModel { Email = model.Email, Message = result.Message});
            }
        }
Пример #3
0
 public ActionResult Logon(LogonViewModel model)
 {
     model.Clients = new List<LoginInfoModel>();
     return View(model);
 }
Пример #4
0
 /// <summary>
 /// Renders home page with login link.
 /// </summary>
 public ActionResult Logon(LogonViewModel model)
 {
     try
     {
         var clients = AuthorizationRoot.Clients.Select(client => new LoginInfoModel
         {
             ProviderName = client.Name
         });
         model.Clients = clients;
         return View(model);
     }
     catch (Exception ex)
     {
         model.Clients = new List<LoginInfoModel>();
         return View(model);
     }
 }