Пример #1
0
        public async Task <IActionResult> ConfirmEmail(string token, string name)
        {
            var decodedUserName = HttpUtility.UrlDecode(name);

            Console.WriteLine($"user name encoded: {name}, user name decoded {decodedUserName}");

            var user = await _personRepository.GetPersonAsync(decodedUserName);

            if (user == null)
            {
                return(View("~/Views/Error.cshtml"));
            }


            Console.WriteLine($"User Compare Token is {user.Token} should match {token}");

            var decodedToken = HttpUtility.UrlDecode(token);

            Console.WriteLine($"User Compare Token is {user.Token} should match decoded token {decodedToken}");

            if (_tokenClass.CompareToken(decodedToken, user.Token) && _tokenClass.CheckTokenDate(user.TokenDate))
            {
                user.EmailConfirmed = "True";
                await _personRepository.UpdatePersonAsync(user);

                return(View("~/Views/ConfirmEmail.cshtml"));
            }
            else
            {
                return(View("~/Views/Error.cshtml"));
            }
        }