Ejemplo n.º 1
0
        public IActionResult ConfirmEmail(string token)
        {
            if (string.IsNullOrEmpty(token))
            {
                Alert.Danger("Invalid token");
                return(View("Error"));
            }

            var parser        = new JwtParser();
            var verifiyResult = parser.VerifyEmailToken(token);

            if (!verifiyResult.IsValid)
            {
                Alert.Danger("InvalidToken");
                return(View("Error"));
            }

            if (!confirmUserEmail.Invoke(verifiyResult.UserId))
            {
                Alert.Danger("User not found or already confirmed");
                return(View("Error"));
            }

            Alert.Success("Email confirmed");
            return(RedirectToAction("Login", "Auth"));
        }