Esempio n. 1
0
        public void ActivationAlreadyLoggedInFailTest()
        {
            var environmentFactory    = EnvironmentFactoryFactory.Create();
            var mailer                = Substitute.For <IMailer>();
            var authenticationContext = Substitute.For <IAuthenticationContext>();

            authenticationContext.GetContextUser().Returns("123456");
            var userOperations  = environmentFactory.ManagementEnvironment.MgmtUserOperations;
            var settingProvider = Substitute.For <ISettingProvider>();

            settingProvider.EmailActivation.Returns(true);

            var userService = new UserService(userOperations, authenticationContext, settingProvider, null);

            var    email          = EmailHelper.Generate();
            string activationCode = null;

            mailer.When(
                m => m.SendActivationMail(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>()))
            .Do(call => { activationCode = (string)call.Args()[3]; });
            var userId = userService.Register(new RegisterDto()
            {
                Name = "new user", Email = email, Password = "******"
            }, mailer);

            userService.Activate(userId, activationCode);
        }
Esempio n. 2
0
        public HttpResponseMessage Activate(string id)
        {
            HttpResponseMessage response = new HttpResponseMessage();

            var activatedUserModel = _userService.Activate(id);

            if (activatedUserModel != null)
            {
                Login(activatedUserModel, true);

                response = Request.CreateResponse(HttpStatusCode.Moved);
                response.Headers.Location = new Uri(ConfigurationManager.AppSettings["HostUrl"]);
            }
            return(response);
        }
Esempio n. 3
0
        public void ActivationInvalidActivationCodeTest()
        {
            var environmentFactory    = EnvironmentFactoryFactory.Create();
            var mailer                = Substitute.For <IMailer>();
            var authenticationContext = Substitute.For <IAuthenticationContext>();

            authenticationContext.GetContextUser().Returns((string)null);
            var userOperations  = environmentFactory.ManagementEnvironment.MgmtUserOperations;
            var settingProvider = Substitute.For <ISettingProvider>();

            settingProvider.EmailActivation.Returns(true);

            var userService = new UserService(userOperations, authenticationContext, settingProvider, null);

            var email = EmailHelper.Generate();

            var userId = userService.Register(new RegisterDto()
            {
                Name = "new user", Email = email, Password = "******"
            }, mailer);

            userService.Activate(userId, Identity.Next());
        }
Esempio n. 4
0
        public IActionResult Activate(string userId, string activationCode)
        {
            _userService.Activate(userId, activationCode);

            return(new NoContentResult());
        }
 public object Activate(User user)
 {
     return(userService.Activate(user));
 }
 public void Activate(string username)
 {
     service.Activate(username);
 }