コード例 #1
0
        public ActionResult Activation(ActivationViewModel model)
        {
            if (!ModelState.IsValid) return View("Activation/Index", model);

            var id = Session["OwnerId"].ToString();
            var ownerId = QueryStringHelper.Base64ForUrlDecode(HttpUtility.UrlDecode(id));

            if (ownerId == string.Format("{0}|{1}", model.Email, model.Password).ToLowerInvariant())
            {
                try
                {
                    const string returnUrl = "/owner/my-listings";                

                    var user = _registrationServices.CreateOwnerUser(model);
                    _registrationServices.UpdateOwnerUserId(model.Email, user.Id);                    

                    _authenticationService.SignIn(user, false);
                    _userEventHandler.LoggedIn(user);
               
                    return Redirect(returnUrl);
                  
                }
                catch
                {
                    const string returnUrl = "/owner/activation-failure";
                    return Redirect(returnUrl);    
                }

            }

            var activationViewModel = new ActivationViewModel()
            {
                Email = model.Email,
                Message = "Your password does not match the registration password, activation failed."
            };

            return View("Activation/Index", activationViewModel);

        }
コード例 #2
0
        public IUser CreateOwnerUser(ActivationViewModel model)
        {           

            var user = _membershipService.CreateUser(new CreateUserParams(model.Email, model.Password, model.Email, null, null, false));
            var roleRecord = _roleService.GetRoleByName("Owner");

            var existingAssociation =
               _userRolesRepository.Get(record => record.UserId == user.Id && record.Role.Id == roleRecord.Id);
            if (existingAssociation == null)
            {
                _userRolesRepository.Create(new UserRolesPartRecord { Role = roleRecord, UserId = user.Id });
            }

            return user;
        }
コード例 #3
0
        public ActionResult Activation(string id)
        {
            Session["OwnerId"] = id;
            var ownerId = QueryStringHelper.Base64ForUrlDecode(HttpUtility.UrlDecode(id));
            var idParts = ownerId.Split('|');

            var activationViewModel = new ActivationViewModel()
            {
                Email = idParts[0],
                Message = "Please confirm your eMail address and password"
            };

            return View("Activation/Index",activationViewModel);
        }