Exemplo n.º 1
0
        public IActionResult ConfirmRegistration(string token)
        {
            var tokenValidation = Jwt.Validate(token, out ClaimsIdentity claimsIdentity);

            if (!tokenValidation)
            {
                return(Unauthorized("Token invalid or expired"));
            }
            if (claimsIdentity.AuthenticationType != TokenScope.Registration)
            {
                return(Unauthorized("JWT was generated for another scope"));
            }

            var username = claimsIdentity.FindFirst(claim => claim.Type == ClaimTypes.Name).Value;

            if (String.IsNullOrEmpty(username))
            {
                return(Problem("Invalid username"));
            }

            UserDatabase.ConfirmAccount(username);
            return(Ok());
        }