public async Task <ActionResult> Activate(string id)
        {
            try
            {
                _logger.Debug("Activating " + id);
                var identity = await _accountService.ActivateAccount(this.ClaimsUser(), id);

                _logger.Debug("Signin " + id);
                await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
                await SignInAsync(identity);

                _logger.Debug("Redirect " + id);
                return(Redirect("~/"));
            }
            catch (ArgumentOutOfRangeException ex)
            {
                _logger.Warn("Failed to activate using " + id, ex);
                ModelState.AddModelError("", "Activation key was not found.");
            }
            catch (Exception err)
            {
                _logger.Warn("Failed to activate using " + id, err);
                ModelState.AddModelError("", err.Message);
            }
            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult ActivateAccount(string userName, string token)
        {
            var result = _accountService.ActivateAccount(userName, token);

            switch (result.Result)
            {
            case EActivateAccountResult.Success:
                return(RedirectToAction("AccountActivated", "Account", new { userName }));

            case EActivateAccountResult.AlreadyActivated:
                return(RedirectToAction("AccountAlreadyActivated", "Account"));

            default:
                return(RedirectToAction("AccountActivationFailed", "Account"));
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> ActivateAccount(string token)
        {
            var response = await _service.ActivateAccount(new Models.ServiceModels.Account.ActivateAccountRequest()
            {
                Token = token
            });

            AddNotifications(response);
            return(RedirectToHome());
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> ActivateAccount([FromQuery] string token)
        {
            var response = await _accountService.ActivateAccount(new ActivateAccountRequest()
            {
                Token = token
            });

            AddNotifications(response);
            return(RedirectToHome());
        }
Ejemplo n.º 5
0
 public ActionResult Confirm(string userEmail, string hash)
 {
     if (service.GetByKey(userEmail) != null && HashService.GenerateUserHash(service.GetByKey(userEmail)) == hash)
     {
         service.ActivateAccount(userEmail, hash);
         return(View());
     }
     else
     {
         return(RedirectToAction("Index", "Home", new { message = userEmail }));
     }
 }
Ejemplo n.º 6
0
        public ActionResult ActivateAccount(string lang, string token)
        {
            var loginPageUrl = AccountRedirectUrls.LoginPage(lang);
            var result       = _accountService.ActivateAccount(token);

            if (result)
            {
                CookiesExtensions.CreateCookie(CookieVariables.TempMessageCookie, "ActivateAccount.Submit.Success");
            }

            return(Redirect(loginPageUrl));
        }
Ejemplo n.º 7
0
        public async Task <ActionResult> Activate(string id)
        {
            try
            {
                var identity = await _accountService.ActivateAccount(this.ClaimsUser(), id);

                SignIn(identity);
                return(Redirect(new ClaimsPrincipal(identity).IsSysAdmin()
                    ? "~/#/welcome/admin/"
                    : "~/#/welcome/user/"));
            }
            catch (Exception err)
            {
                ModelState.AddModelError("", err.Message);
                return(View());
            }
        }
Ejemplo n.º 8
0
        public ActionResult Activate(string activationCode)
        {
            if (activationCode == null)
            {
                throw new ArgumentNullException(nameof(activationCode));
            }

            var message = accountService.ActivateAccount(activationCode);

            if (message == string.Empty)
            {
                message = "Your account is activated";
            }

            //Generate the View From the Factory
            var model = accountService.GenerateActivationView(message);


            return(this.View("Activate", model));
        }