diff --git a/TickAPI/TickAPI.Tests/Common/Auth/Services/GoogleAuthServiceTests.cs b/TickAPI/TickAPI.Tests/Common/Auth/Services/GoogleAuthServiceTests.cs index ad5e695..c9c3824 100644 --- a/TickAPI/TickAPI.Tests/Common/Auth/Services/GoogleAuthServiceTests.cs +++ b/TickAPI/TickAPI.Tests/Common/Auth/Services/GoogleAuthServiceTests.cs @@ -10,22 +10,24 @@ namespace TickAPI.Tests.Common.Auth.Services; public class GoogleAuthServiceTests { [Fact] - public async Task LoginAsync_WhenTokenValidatorReturnsPayload_ShouldReturnEmailFromPayload() + public async Task GetUserDataFromToken_WhenTokenValidatorReturnsPayload_ShouldReturnEmailFromPayload() { var googleTokenValidatorMock = new Mock(); googleTokenValidatorMock .Setup(m => m.ValidateAsync("validToken")) - .ReturnsAsync(new GoogleJsonWebSignature.Payload { Email = "example@test.com" }); + .ReturnsAsync(new GoogleJsonWebSignature.Payload { Email = "example@test.com", GivenName = "First", FamilyName = "Last"}); var sut = new GoogleAuthService(googleTokenValidatorMock.Object); - var result = await sut.LoginAsync("validToken"); + var result = await sut.GetUserDataFromToken("validToken"); Assert.True(result.IsSuccess); - Assert.Equal("example@test.com", result.Value); + Assert.Equal("example@test.com", result.Value?.Email); + Assert.Equal("First", result.Value?.FirstName); + Assert.Equal("Last", result.Value?.LastName); } [Fact] - public async Task LoginAsync_WhenTokenValidatorThrowsException_ShouldReturnFailure() + public async Task GetUserDataFromToken_WhenTokenValidatorThrowsException_ShouldReturnFailure() { var googleTokenValidatorMock = new Mock(); googleTokenValidatorMock @@ -33,7 +35,7 @@ public async Task LoginAsync_WhenTokenValidatorThrowsException_ShouldReturnFailu .Throws(new InvalidJwtException("Invalid Google ID token")); var sut = new GoogleAuthService(googleTokenValidatorMock.Object); - var result = await sut.LoginAsync("invalidToken"); + var result = await sut.GetUserDataFromToken("invalidToken"); Assert.True(result.IsError); Assert.Equal(StatusCodes.Status401Unauthorized, result.StatusCode); diff --git a/TickAPI/TickAPI.Tests/Customers/Controllers/CustomerControllerTests.cs b/TickAPI/TickAPI.Tests/Customers/Controllers/CustomerControllerTests.cs index d36ac0f..9c8079b 100644 --- a/TickAPI/TickAPI.Tests/Customers/Controllers/CustomerControllerTests.cs +++ b/TickAPI/TickAPI.Tests/Customers/Controllers/CustomerControllerTests.cs @@ -4,6 +4,7 @@ using Moq; using TickAPI.Common.Auth.Abstractions; using TickAPI.Common.Auth.Enums; +using TickAPI.Common.Auth.Responses; using TickAPI.Common.Result; using TickAPI.Customers.Abstractions; using TickAPI.Customers.Controllers; @@ -15,15 +16,16 @@ namespace TickAPI.Tests.Customers.Controllers; public class CustomerControllerTests { [Fact] - public async Task GoogleLogin_WhenAuthSuccessAndCustomerExists_ShouldReturnTokenAndNotNewCustomer() + public async Task GoogleLogin_WhenAuthSuccessAndCustomerExists_ShouldReturnToken() { + // Arrange const string email = "existing@test.com"; const string idToken = "valid-google-token"; const string jwtToken = "valid-jwt-token"; - var authServiceMock = new Mock(); - authServiceMock.Setup(m => m.LoginAsync(idToken)) - .ReturnsAsync(Result.Success(email)); + var googleAuthServiceMock = new Mock(); + googleAuthServiceMock.Setup(m => m.GetUserDataFromToken(idToken)) + .ReturnsAsync(Result.Success(new GoogleUserData(email, "First", "Last"))); var customerServiceMock = new Mock(); customerServiceMock.Setup(m => m.GetCustomerByEmailAsync(email)) @@ -34,115 +36,142 @@ public async Task GoogleLogin_WhenAuthSuccessAndCustomerExists_ShouldReturnToken .Returns(Result.Success(jwtToken)); var sut = new CustomerController( - authServiceMock.Object, + googleAuthServiceMock.Object, jwtServiceMock.Object, customerServiceMock.Object); + // Act var actionResult = await sut.GoogleLogin(new GoogleLoginDto(idToken)); + // Assert Assert.Equal(jwtToken, actionResult.Value?.Token); - Assert.False(actionResult.Value?.IsNewCustomer); } [Fact] - public async Task GoogleLogin_WhenAuthSuccessAndCustomerDoesNotExist_ShouldReturnTokenAndNewCustomer() + public async Task GoogleLogin_WhenAuthSuccessAndCustomerDoesNotExist_ShouldCreateCustomerAndReturnToken() { + // Arrange const string email = "new@test.com"; const string idToken = "valid-google-token"; + const string firstName = "First"; + const string lastName = "Last"; const string jwtToken = "valid-jwt-token"; - var authServiceMock = new Mock(); - authServiceMock.Setup(m => m.LoginAsync(idToken)) - .ReturnsAsync(Result.Success(email)); + var googleAuthServiceMock = new Mock(); + googleAuthServiceMock.Setup(m => m.GetUserDataFromToken(idToken)) + .ReturnsAsync(Result.Success(new GoogleUserData(email, "First", "Last"))); var customerServiceMock = new Mock(); customerServiceMock.Setup(m => m.GetCustomerByEmailAsync(email)) .ReturnsAsync(Result.Failure(StatusCodes.Status404NotFound, $"customer with email '{email}' not found")); + customerServiceMock.Setup(m => m.CreateNewCustomerAsync(email, firstName, lastName)) + .ReturnsAsync(Result.Success(new Customer + { + Id = Guid.NewGuid(), + Email = email, + FirstName = firstName, + LastName = lastName + })); var jwtServiceMock = new Mock(); - jwtServiceMock.Setup(m => m.GenerateJwtToken(email, UserRole.NewCustomer)) + jwtServiceMock.Setup(m => m.GenerateJwtToken(email, UserRole.Customer)) .Returns(Result.Success(jwtToken)); var sut = new CustomerController( - authServiceMock.Object, + googleAuthServiceMock.Object, jwtServiceMock.Object, customerServiceMock.Object); - var result = await sut.GoogleLogin(new GoogleLoginDto(idToken)); + // Act + var result = await sut.GoogleLogin(new GoogleLoginDto( idToken )); + // Assert Assert.Equal(jwtToken, result.Value?.Token); - Assert.True(result.Value?.IsNewCustomer); } [Fact] - public async Task GoogleCreateNewAccount_WhenCreatingAccountIsSuccessful_ShouldReturnToken() + public async Task AboutMe_WithValidEmailClaim_ShouldReturnCustomerDetails() { - const string email = "new@test.com"; - const string firstName = "First"; - const string lastName = "Last"; - const string jwtToken = "valid-jwt-token"; + // Arrange + const string email = "test@example.com"; + const string firstName = "John"; + const string lastName = "Doe"; + var creationDate = new DateTime(1970, 1, 1, 8, 0, 0, DateTimeKind.Utc); + + var customer = new Customer + { + Email = email, + FirstName = firstName, + LastName = lastName, + CreationDate = creationDate + }; - var authServiceMock = new Mock(); var customerServiceMock = new Mock(); - customerServiceMock.Setup(m => m.CreateNewCustomerAsync(email, firstName, lastName)) - .ReturnsAsync(Result.Success(new Customer - { - Id = Guid.NewGuid(), - Email = email, - FirstName = firstName, - LastName = lastName - })); + customerServiceMock.Setup(m => m.GetCustomerByEmailAsync(email)) + .ReturnsAsync(Result.Success(customer)); + var googleAuthServiceMock = new Mock(); var jwtServiceMock = new Mock(); - jwtServiceMock.Setup(m => m.GenerateJwtToken(email, UserRole.Customer)) - .Returns(Result.Success(jwtToken)); var sut = new CustomerController( - authServiceMock.Object, - jwtServiceMock.Object, + googleAuthServiceMock.Object, + jwtServiceMock.Object, customerServiceMock.Object); var claims = new List { new Claim(ClaimTypes.Email, email) }; + var identity = new ClaimsIdentity(claims); + var claimsPrincipal = new ClaimsPrincipal(identity); + sut.ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext { - User = new ClaimsPrincipal(new ClaimsIdentity(claims)) + User = claimsPrincipal } }; - var result = await sut.GoogleCreateNewAccount( - new GoogleCreateNewAccountDto( firstName, lastName )); + // Act + var result = await sut.AboutMe(); - Assert.Equal(jwtToken, result.Value?.Token); + // Assert + Assert.Equal(email, result.Value?.Email); + Assert.Equal(firstName, result.Value?.FirstName); + Assert.Equal(lastName, result.Value?.LastName); + Assert.Equal(creationDate, result.Value?.CreationDate); } - + [Fact] - public async Task GoogleCreateNewAccount_WhenEmailClaimIsMissing_ShouldReturnBadRequest() + public async Task AboutMe_WithMissingEmailClaim_ShouldReturnBadRequest() { - var authServiceMock = new Mock(); - var jwtServiceMock = new Mock(); + // Arrange var customerServiceMock = new Mock(); - + var googleAuthServiceMock = new Mock(); + var jwtServiceMock = new Mock(); + var sut = new CustomerController( - authServiceMock.Object, - jwtServiceMock.Object, + googleAuthServiceMock.Object, + jwtServiceMock.Object, customerServiceMock.Object); - + + var claims = new List(); + var identity = new ClaimsIdentity(claims); + var claimsPrincipal = new ClaimsPrincipal(identity); + sut.ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext { - User = new ClaimsPrincipal(new ClaimsIdentity(new List())) + User = claimsPrincipal } }; - - var result = await sut.GoogleCreateNewAccount( - new GoogleCreateNewAccountDto("First","Last")); - + + // Act + var result = await sut.AboutMe(); + + // Assert var objectResult = Assert.IsType(result.Result); Assert.Equal(StatusCodes.Status400BadRequest, objectResult.StatusCode); Assert.Equal("missing email claim", objectResult.Value); diff --git a/TickAPI/TickAPI/Common/Auth/Abstractions/IAuthService.cs b/TickAPI/TickAPI/Common/Auth/Abstractions/IAuthService.cs deleted file mode 100644 index df0f33f..0000000 --- a/TickAPI/TickAPI/Common/Auth/Abstractions/IAuthService.cs +++ /dev/null @@ -1,8 +0,0 @@ -using TickAPI.Common.Result; - -namespace TickAPI.Common.Auth.Abstractions; - -public interface IAuthService -{ - Task> LoginAsync(string idToken); -} \ No newline at end of file diff --git a/TickAPI/TickAPI/Common/Auth/Abstractions/IGoogleAuthService.cs b/TickAPI/TickAPI/Common/Auth/Abstractions/IGoogleAuthService.cs new file mode 100644 index 0000000..039e75c --- /dev/null +++ b/TickAPI/TickAPI/Common/Auth/Abstractions/IGoogleAuthService.cs @@ -0,0 +1,9 @@ +using TickAPI.Common.Auth.Responses; +using TickAPI.Common.Result; + +namespace TickAPI.Common.Auth.Abstractions; + +public interface IGoogleAuthService +{ + Task> GetUserDataFromToken(string token); +} \ No newline at end of file diff --git a/TickAPI/TickAPI/Common/Auth/Controllers/AuthController.cs b/TickAPI/TickAPI/Common/Auth/Controllers/AuthController.cs index bdeedc5..6483535 100644 --- a/TickAPI/TickAPI/Common/Auth/Controllers/AuthController.cs +++ b/TickAPI/TickAPI/Common/Auth/Controllers/AuthController.cs @@ -8,12 +8,12 @@ namespace TickAPI.Common.Auth.Controllers; [Route("api/[controller]")] public class AuthController : ControllerBase { - private readonly IAuthService _authService; + private readonly IGoogleAuthService _googleAuthService; private readonly IJwtService _jwtService; - public AuthController(IAuthService authService, IJwtService jwtService) + public AuthController(IGoogleAuthService googleAuthService, IJwtService jwtService) { - _authService = authService; + _googleAuthService = googleAuthService; _jwtService = jwtService; } @@ -22,12 +22,12 @@ public AuthController(IAuthService authService, IJwtService jwtService) [HttpPost("google-login")] public async Task GoogleLogin([FromBody] GoogleLoginRequest request) { - var loginResult = await _authService.LoginAsync(request.IdToken); + var userDataResult = await _googleAuthService.GetUserDataFromToken(request.IdToken); - if(loginResult.IsError) - return StatusCode(loginResult.StatusCode, loginResult.ErrorMsg); + if(userDataResult.IsError) + return StatusCode(userDataResult.StatusCode, userDataResult.ErrorMsg); - var jwtTokenResult = _jwtService.GenerateJwtToken(loginResult.Value, UserRole.Customer); + var jwtTokenResult = _jwtService.GenerateJwtToken(userDataResult.Value?.Email, UserRole.Customer); if(jwtTokenResult.IsError) return StatusCode(jwtTokenResult.StatusCode, jwtTokenResult.ErrorMsg); diff --git a/TickAPI/TickAPI/Common/Auth/Enums/AuthPolicies.cs b/TickAPI/TickAPI/Common/Auth/Enums/AuthPolicies.cs index ec06e2e..c5d6408 100644 --- a/TickAPI/TickAPI/Common/Auth/Enums/AuthPolicies.cs +++ b/TickAPI/TickAPI/Common/Auth/Enums/AuthPolicies.cs @@ -6,5 +6,4 @@ public enum AuthPolicies OrganizerPolicy, CustomerPolicy, NewOrganizerPolicy, - NewCustomerPolicy, } \ No newline at end of file diff --git a/TickAPI/TickAPI/Common/Auth/Enums/UserRole.cs b/TickAPI/TickAPI/Common/Auth/Enums/UserRole.cs index 93e3677..d382a54 100644 --- a/TickAPI/TickAPI/Common/Auth/Enums/UserRole.cs +++ b/TickAPI/TickAPI/Common/Auth/Enums/UserRole.cs @@ -6,5 +6,4 @@ public enum UserRole Organizer, Customer, NewOrganizer, - NewCustomer, } \ No newline at end of file diff --git a/TickAPI/TickAPI/Common/Auth/Responses/GoogleUserData.cs b/TickAPI/TickAPI/Common/Auth/Responses/GoogleUserData.cs new file mode 100644 index 0000000..d317e07 --- /dev/null +++ b/TickAPI/TickAPI/Common/Auth/Responses/GoogleUserData.cs @@ -0,0 +1,7 @@ +namespace TickAPI.Common.Auth.Responses; + +public record GoogleUserData( + string Email, + string FirstName, + string LastName +); \ No newline at end of file diff --git a/TickAPI/TickAPI/Common/Auth/Services/GoogleAuthService.cs b/TickAPI/TickAPI/Common/Auth/Services/GoogleAuthService.cs index 4abf2ad..b8fc876 100644 --- a/TickAPI/TickAPI/Common/Auth/Services/GoogleAuthService.cs +++ b/TickAPI/TickAPI/Common/Auth/Services/GoogleAuthService.cs @@ -1,10 +1,10 @@ -using Google.Apis.Auth; -using TickAPI.Common.Auth.Abstractions; +using TickAPI.Common.Auth.Abstractions; +using TickAPI.Common.Auth.Responses; using TickAPI.Common.Result; namespace TickAPI.Common.Auth.Services; -public class GoogleAuthService : IAuthService +public class GoogleAuthService : IGoogleAuthService { private readonly IGoogleTokenValidator _googleTokenValidator; @@ -13,16 +13,17 @@ public GoogleAuthService(IGoogleTokenValidator googleTokenValidator) _googleTokenValidator = googleTokenValidator; } - public async Task> LoginAsync(string idToken) + public async Task> GetUserDataFromToken(string idToken) { try { var payload = await _googleTokenValidator.ValidateAsync(idToken); - return Result.Success(payload.Email); + var userData = new GoogleUserData(payload.Email, payload.GivenName, payload.FamilyName); + return Result.Success(userData); } catch (Exception) { - return Result.Failure(StatusCodes.Status401Unauthorized, "Invalid Google ID token"); + return Result.Failure(StatusCodes.Status401Unauthorized, "Invalid Google ID token"); } } } \ No newline at end of file diff --git a/TickAPI/TickAPI/Common/Auth/Services/GoogleTokenValidator.cs b/TickAPI/TickAPI/Common/Auth/Services/GoogleTokenValidator.cs index 060a2f0..a6bd4d4 100644 --- a/TickAPI/TickAPI/Common/Auth/Services/GoogleTokenValidator.cs +++ b/TickAPI/TickAPI/Common/Auth/Services/GoogleTokenValidator.cs @@ -1,6 +1,8 @@ using Google.Apis.Auth; using TickAPI.Common.Auth.Abstractions; +namespace TickAPI.Common.Auth.Services; + public class GoogleTokenValidator : IGoogleTokenValidator { private readonly IConfiguration _configuration; diff --git a/TickAPI/TickAPI/Customers/Controllers/CustomerController.cs b/TickAPI/TickAPI/Customers/Controllers/CustomerController.cs index fabb150..ea02b83 100644 --- a/TickAPI/TickAPI/Customers/Controllers/CustomerController.cs +++ b/TickAPI/TickAPI/Customers/Controllers/CustomerController.cs @@ -13,13 +13,13 @@ namespace TickAPI.Customers.Controllers; [Route("api/[controller]")] public class CustomerController : ControllerBase { - private readonly IAuthService _authService; + private readonly IGoogleAuthService _googleAuthService; private readonly IJwtService _jwtService; private readonly ICustomerService _customerService; - public CustomerController(IAuthService authService, IJwtService jwtService, ICustomerService customerService) + public CustomerController(IGoogleAuthService googleAuthService, IJwtService jwtService, ICustomerService customerService) { - _authService = authService; + _googleAuthService = googleAuthService; _jwtService = jwtService; _customerService = customerService; } @@ -27,48 +27,44 @@ public CustomerController(IAuthService authService, IJwtService jwtService, ICus [HttpPost("google-login")] public async Task> GoogleLogin([FromBody] GoogleLoginDto request) { - var loginResult = await _authService.LoginAsync(request.IdToken); - if(loginResult.IsError) - return StatusCode(loginResult.StatusCode, loginResult.ErrorMsg); + var userDataResult = await _googleAuthService.GetUserDataFromToken(request.IdToken); + if(userDataResult.IsError) + return StatusCode(userDataResult.StatusCode, userDataResult.ErrorMsg); - UserRole role; - bool isNewCustomer; + var userData = userDataResult.Value!; - var existingCustomerResult = await _customerService.GetCustomerByEmailAsync(loginResult.Value!); - if (existingCustomerResult.IsSuccess) + var existingCustomerResult = await _customerService.GetCustomerByEmailAsync(userData.Email); + if (existingCustomerResult.IsError) { - role = UserRole.Customer; - isNewCustomer = false; - } - else - { - role = UserRole.NewCustomer; - isNewCustomer = true; + var newCustomerResult = await _customerService.CreateNewCustomerAsync(userData.Email, userData.FirstName, userData.LastName); + if (newCustomerResult.IsError) + return StatusCode(newCustomerResult.StatusCode, newCustomerResult.ErrorMsg); } - var jwtTokenResult = _jwtService.GenerateJwtToken(loginResult.Value, role); + var jwtTokenResult = _jwtService.GenerateJwtToken(userData.Email, UserRole.Customer); if (jwtTokenResult.IsError) return StatusCode(jwtTokenResult.StatusCode, jwtTokenResult.ErrorMsg); - return new ActionResult(new GoogleLoginResponseDto(jwtTokenResult.Value!, isNewCustomer)); + return new ActionResult(new GoogleLoginResponseDto(jwtTokenResult.Value!)); } - [AuthorizeWithPolicy(AuthPolicies.NewCustomerPolicy)] - [HttpPost("google-create-new-account")] - public async Task> GoogleCreateNewAccount([FromBody] GoogleCreateNewAccountDto request) + [AuthorizeWithPolicy(AuthPolicies.CustomerPolicy)] + [HttpGet("about-me")] + public async Task> AboutMe() { var email = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Email)?.Value; if (email == null) return StatusCode(StatusCodes.Status400BadRequest, "missing email claim"); - - var newCustomerResult = await _customerService.CreateNewCustomerAsync(email, request.FirstName, request.LastName); - if (newCustomerResult.IsError) - return StatusCode(newCustomerResult.StatusCode, newCustomerResult.ErrorMsg); - - var jwtTokenResult = _jwtService.GenerateJwtToken(newCustomerResult.Value!.Email, UserRole.Customer); - if (jwtTokenResult.IsError) - return StatusCode(jwtTokenResult.StatusCode, jwtTokenResult.ErrorMsg); - return new ActionResult(new GoogleCreateNewAccountResponseDto(jwtTokenResult.Value!)); + var customerResult = await _customerService.GetCustomerByEmailAsync(email); + if (customerResult.IsError) + return StatusCode(StatusCodes.Status500InternalServerError, + "cannot find customer in database for authorized customer request"); + + var customer = customerResult.Value!; + + var aboutMeResponse = + new AboutMeResponseDto(customer.Email, customer.FirstName, customer.LastName, customer.CreationDate); + return new ActionResult(aboutMeResponse); } } \ No newline at end of file diff --git a/TickAPI/TickAPI/Customers/DTOs/Request/GoogleCreateNewAccountDto.cs b/TickAPI/TickAPI/Customers/DTOs/Request/GoogleCreateNewAccountDto.cs deleted file mode 100644 index f896265..0000000 --- a/TickAPI/TickAPI/Customers/DTOs/Request/GoogleCreateNewAccountDto.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace TickAPI.Customers.DTOs.Request; - -public record GoogleCreateNewAccountDto( - string FirstName, - string LastName -); \ No newline at end of file diff --git a/TickAPI/TickAPI/Customers/DTOs/Response/AboutMeResponseDto.cs b/TickAPI/TickAPI/Customers/DTOs/Response/AboutMeResponseDto.cs new file mode 100644 index 0000000..c813f55 --- /dev/null +++ b/TickAPI/TickAPI/Customers/DTOs/Response/AboutMeResponseDto.cs @@ -0,0 +1,8 @@ +namespace TickAPI.Customers.DTOs.Response; + +public record AboutMeResponseDto( + string Email, + string FirstName, + string LastName, + DateTime CreationDate +); \ No newline at end of file diff --git a/TickAPI/TickAPI/Customers/DTOs/Response/GoogleCreateNewAccountResponseDto.cs b/TickAPI/TickAPI/Customers/DTOs/Response/GoogleCreateNewAccountResponseDto.cs deleted file mode 100644 index b49ac83..0000000 --- a/TickAPI/TickAPI/Customers/DTOs/Response/GoogleCreateNewAccountResponseDto.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace TickAPI.Customers.DTOs.Response; - -public record GoogleCreateNewAccountResponseDto( - string Token -); \ No newline at end of file diff --git a/TickAPI/TickAPI/Customers/DTOs/Response/GoogleLoginResponseDto.cs b/TickAPI/TickAPI/Customers/DTOs/Response/GoogleLoginResponseDto.cs index b2d5434..0090b70 100644 --- a/TickAPI/TickAPI/Customers/DTOs/Response/GoogleLoginResponseDto.cs +++ b/TickAPI/TickAPI/Customers/DTOs/Response/GoogleLoginResponseDto.cs @@ -1,6 +1,5 @@ namespace TickAPI.Customers.DTOs.Response; public record GoogleLoginResponseDto( - string Token, - bool IsNewCustomer + string Token ); \ No newline at end of file diff --git a/TickAPI/TickAPI/Program.cs b/TickAPI/TickAPI/Program.cs index 725812a..0faecf6 100644 --- a/TickAPI/TickAPI/Program.cs +++ b/TickAPI/TickAPI/Program.cs @@ -69,7 +69,6 @@ options.AddPolicy(AuthPolicies.CustomerPolicy.ToString(), policy => policy.RequireRole(UserRole.Customer.ToString())); options.AddPolicy(AuthPolicies.NewOrganizerPolicy.ToString(), policy => policy.RequireRole(UserRole.NewOrganizer.ToString())); - options.AddPolicy(AuthPolicies.NewCustomerPolicy.ToString(), policy => policy.RequireRole(UserRole.NewCustomer.ToString())); }); // Add admin services. @@ -93,7 +92,7 @@ builder.Services.AddScoped(); // Add common services. -builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped();