예제 #1
0
        public void Should_Reject_Duplicate_EmailAddress()
        {
            // Arrange
            repository.GetCredentials(Arg.Any <string>()).Returns(new Credentials {
                Email = "*****@*****.**"
            });
            IUser        newUser     = NewTestUser();
            ICredentials credentials = NewTestCredentials();

            // Act
            accountBusiness.SignUp(newUser, credentials);
        }
예제 #2
0
        public IHttpActionResult RegisterNewUser(NewAccountModel newAccount)
        {
            try
            {
                IUser newUser = accountBusiness.SignUp(new User
                {
                    UserName = newAccount.UserName,
                    Email    = newAccount.Email
                },
                                                       new Credentials
                {
                    Email    = newAccount.Email,
                    Password = newAccount.Password
                });
                //generate access token response
                var accessTokenResponse = GenerateLocalAccessTokenResponse(newUser);

                // Return success with the bearer token for authorized access
                return(Ok(new { token = accessTokenResponse, profile = newUser }));
            }
            catch (UserAlreadyRegisteredException)
            {
                return(BadRequest("A user with this email address is already registered."));
            }
        }