Exemplo n.º 1
0
 public ActionResult Create(RegisterUser model)
 {
     if (ModelState.IsValid)
     {
         _regUserService.Save(model);
         var result = _userValidate.Execute(new ValidationParameters {
             Email = model.Email, Password = model.Password
         });
         if (result.IsAuthenticated)
         {
             _authService.SetUserData(new UserInfo
             {
                 UserId          = result.UserId,
                 Name            = result.Name,
                 Role            = result.Role,
                 RoleId          = result.RoleId,
                 IsAuthenticated = result.IsAuthenticated,
                 Email           = result.Email,
                 Roles           = result.Roles
             });
             return(RedirectToAction("Index", "Store"));
         }
     }
     return(RedirectToAction("Create", "Register"));
 }
Exemplo n.º 2
0
 public ActionResult Login(ValidationParameters parameterModel)
 {
     if (ModelState.IsValid)
     {
         var result = _userValidate.Execute(parameterModel);
         if (result.IsAuthenticated)
         {
             _authService.SetUserData(new UserInfo
             {
                 UserId          = result.UserId,
                 Name            = result.Name,
                 Role            = result.Role,
                 RoleId          = result.RoleId,
                 IsAuthenticated = result.IsAuthenticated,
                 Email           = result.Email,
                 Roles           = result.Roles
             });
             return(RedirectToAction("Index", "Store"));
         }
     }
     return(View(parameterModel));
 }