Esempio n. 1
0
        public async Task <ActionResult <AuthorizationResponse> > RefreshToken([FromBody] string existingRefreshToken)
        {
            UserRefreshToken userRefreshToken = await _jwtTokenService.GetExistingRefreshToken(existingRefreshToken);

            if (userRefreshToken != null)
            {
                JwtSecurityToken jwtSecurityToken = _jwtTokenService.GetJwtSecurityToken(userRefreshToken.JwtToken);
                List <Claim>     existingClaims   = jwtSecurityToken.Claims.ToList();
                string           email            = existingClaims.First(x => x.Type == ClaimTypes.Name).Value;

                string refreshToken            = userRefreshToken.RefreshToken;
                AuthorizationResponse response = await CreateNewJwtAndStoreWithRefreshToken(refreshToken, email, existingClaims);

                return(Ok(response));
            }

            return(StatusCode(StatusCodes.Status404NotFound));
        }