Exemple #1
0
 public void Register(AccountViewModel model)
 {
     userService.Register(
         new UserDTO
         {
             UserName = model.UserName
         },
         model.Password);
 }
Exemple #2
0
        public void Login(AccountViewModel model)
        {
            var password = userService.GetPasswordByUserName(model.UserName);
            if (PasswordHash.ValidatePassword(model.Password, password))
            {
                var user = userService.GetByUserName(model.UserName);

                var authenticationService = AuthenticationFactory.CreateAuthentication();

                var serializeModel = new CustomPrincipalSerializeModel();
                serializeModel.UserID = user.ID;
                //serializeModel.FirstName = user.FirstName;
                //serializeModel.LastName = user.LastName;
                serializeModel.UserName = user.UserName;
                serializeModel.Roles = user.Roles.Select(r => r.ID.ToString()).ToArray();

                var serializer = new JavaScriptSerializer();
                var userData = serializer.Serialize(serializeModel);

                authenticationService.Login(model.UserName, model.Password, model.IsRememberMe, userData);
            }
        }
Exemple #3
0
        public ActionResult LogOn(AccountViewModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                accountTask.Login(model);

                if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                    && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                {
                    return Redirect(returnUrl);
                }
                else
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            else
            {
                ModelState.AddModelError("", "The user name or password provided is incorrect.");
            }

            return View(model);
        }
Exemple #4
0
 public ActionResult Register(AccountViewModel model)
 {
     accountTask.Register(model);
     return RedirectToAction("LogOn");
 }