Ejemplo n.º 1
0
        public override void SetUp()
        {
            base.SetUp();

            expectedViewModel = new RegisterViewModel()
            {
                EmailAddress = "email",
                Password = "******",
                UserName = "******",
                GamingGroupInvitationId = Guid.NewGuid().ToString()
            };
        }
 public ActionResult Register(RegisterViewModel model)
 {
     if (ModelState.IsValid)
     {
         ApplicationUserDTO userDto = new ApplicationUserDTO
         {
             UserName = model.Email,
             Password = model.Password,
             UserProfileName = model.UserProfileName
         };
         OperationDetails operationDetails = _userService.CreateUser(userDto);
         if (operationDetails.Succedeed)
             return RedirectToAction("Login", "Account");
         ModelState.AddModelError(operationDetails.Property, operationDetails.Message);
     }
     return View(model);
 }
Ejemplo n.º 3
0
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);
                    
                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return RedirectToAction("Index", "Home");
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
        public virtual void SetUp()
        {
            userStoreMock = MockRepository.GenerateMock<IUserStore<ApplicationUser>>();
            gamingGroupInviteConsumerMock = MockRepository.GenerateMock<IGamingGroupInviteConsumer>();
            userRegistererMock = MockRepository.GenerateMock<IUserRegisterer>();
            this.firstTimeAuthenticatorMock = MockRepository.GenerateMock<IFirstTimeAuthenticator>();
            this.authenticationManagerMock = MockRepository.GenerateMock<IAuthenticationManager>();
            var dataProtector = MockRepository.GenerateMock<IDataProtector>();
            dataProtectionProviderMock = MockRepository.GenerateMock<IDataProtectionProvider>();
            gamingGroupRetrieverMock = MockRepository.GenerateMock<IGamingGroupRetriever>();
            
            boardGameGeekUserSaver = MockRepository.GenerateMock<IBoardGameGeekUserSaver>();
            boardGameGeekApiClient = MockRepository.GenerateMock<IBoardGameGeekApiClient>();
            userRetriever = MockRepository.GenerateMock<IUserRetriever>();

            dataProtectionProviderMock.Expect(mock => mock.Create(Arg<string>.Is.Anything)).Return(dataProtector);

            userManager = new ApplicationUserManager(userStoreMock, dataProtectionProviderMock);
            accountControllerPartialMock = MockRepository.GeneratePartialMock<AccountController>(
                userManager,
                userRegistererMock,
                this.firstTimeAuthenticatorMock,
                this.authenticationManagerMock,
                gamingGroupInviteConsumerMock, 
                gamingGroupRetrieverMock,
                boardGameGeekUserSaver,
                boardGameGeekApiClient,
                userRetriever);
            currentUser = new ApplicationUser()
            {
                Id = "new application user",
                CurrentGamingGroupId = 1
            };
            registerViewModel = new RegisterViewModel()
            {
                ConfirmPassword = "******",
                Password = "******",
                UserName = "******",
                EmailAddress = "*****@*****.**"
            };
        }
Ejemplo n.º 5
0
        public virtual ActionResult ConsumeInvitation(string id, ApplicationUser currentUser)
        {
            AddUserToGamingGroupResult result = gamingGroupInvitationConsumer.AddExistingUserToGamingGroup(id);

            if (result.UserAddedToExistingGamingGroup)
            {
                return RedirectToAction(MVC.GamingGroup.ActionNames.Index, MVC.GamingGroup.Name);
            }

            RegisterViewModel registerViewModel = new RegisterViewModel
            {
                EmailAddress = result.EmailAddress,
                GamingGroupInvitationId = id
            };

            return this.View(MVC.Account.Views.RegisterAgainstExistingGamingGroup, registerViewModel);
        }
Ejemplo n.º 6
0
        public virtual async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                Guid? gamingGroupInvitation = null;
                if (!string.IsNullOrWhiteSpace(model.GamingGroupInvitationId))
                {
                    gamingGroupInvitation = new Guid(model.GamingGroupInvitationId);
                }

                NewUser newUser = new NewUser
                {
                    EmailAddress = model.EmailAddress.Trim(),
                    UserName = model.UserName.Trim(),
                    Password = model.Password,
                    GamingGroupInvitationId = gamingGroupInvitation
                };

                RegisterNewUserResult registerNewUserResult = await this.userRegisterer.RegisterUser(newUser);

                if (registerNewUserResult.Result.Succeeded)
                {
                    return RedirectToAction(MVC.GamingGroup.ActionNames.Index, MVC.GamingGroup.Name);
                }
                this.AddErrors(registerNewUserResult.Result);
            }

            // If we got this far, something failed, redisplay form
            return View(MVC.Account.Views.Register, model);
        }