diff --git a/Klika.AuthApi.Service/User/UserService.cs b/Klika.AuthApi.Service/User/UserService.cs index c2655f9..9c0b565 100644 --- a/Klika.AuthApi.Service/User/UserService.cs +++ b/Klika.AuthApi.Service/User/UserService.cs @@ -41,14 +41,15 @@ public async Task Register(ApplicationUserDTO user) try { ApplicationUser applicationUser = _mapper.Map(user); - var identityResult = await _userManager.CreateAsync(applicationUser, user.Password); + var identityResult = await _userManager.CreateAsync(applicationUser, user.Password).ConfigureAwait(false); if (identityResult.Succeeded) { await _userManager.AddClaimsAsync(applicationUser, new List() { new Claim("email", applicationUser.Email) - }); - await _userManager.AddToRolesAsync(applicationUser, new List() { "admin" }); // Define user roles on registration + }).ConfigureAwait(false); + await _userManager.AddToRolesAsync(applicationUser, new List() { "admin" }) + .ConfigureAwait(false); // Define user roles on registration } return identityResult; @@ -81,7 +82,7 @@ public async Task Token(TokenRequestDTO tokenRequest) Scope = tokenRequest.Scope, UserName = tokenRequest.Username, Password = tokenRequest.Password - }); + }).ConfigureAwait(false); return passwordFlow; case "client_credentials": var clientCredentialsFlow = await client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest() @@ -90,7 +91,7 @@ public async Task Token(TokenRequestDTO tokenRequest) ClientId = tokenRequest.ClientId, ClientSecret = tokenRequest.ClientSecret, Scope = tokenRequest.Scope, - }); + }).ConfigureAwait(false); return clientCredentialsFlow; default: throw new Exception("grant_type is not supported"); @@ -121,7 +122,7 @@ public async Task RefreshToken(TokenRequestDTO tokenRequest) ClientId = tokenRequest.ClientId, ClientSecret = tokenRequest.ClientSecret, RefreshToken = tokenRequest.RefreshToken - }); + }).ConfigureAwait(false); return refreshToken; } catch (Exception ex) @@ -148,7 +149,7 @@ public async Task RevokeToken(TokenRequestDTO tokenRequ ClientId = tokenRequest.ClientId, ClientSecret = tokenRequest.ClientSecret, Token = tokenRequest.RefreshToken - }); + }).ConfigureAwait(false); return revokeResult; } catch (Exception ex) diff --git a/Klika.AuthApi/Controllers/IdentityController.cs b/Klika.AuthApi/Controllers/IdentityController.cs index f82bc4e..b39c16e 100644 --- a/Klika.AuthApi/Controllers/IdentityController.cs +++ b/Klika.AuthApi/Controllers/IdentityController.cs @@ -33,7 +33,8 @@ public async Task> Register([FromBody] ApplicationU { try { - IdentityResult result = await _userService.Register(user); + IdentityResult result = await _userService.Register(user) + .ConfigureAwait(false); if (result.Succeeded) return Ok(result); @@ -52,7 +53,8 @@ public async Task Token([FromBody] TokenRequestDTO tokenRequest) { try { - TokenResponse result = await _userService.Token(tokenRequest); + TokenResponse result = await _userService.Token(tokenRequest) + .ConfigureAwait(false); if (!result.IsError) return Ok(result.Json); return Conflict(result.Json); @@ -70,7 +72,8 @@ public async Task RefreshToken([FromBody] TokenRequestDTO tokenRe { try { - TokenResponse result = await _userService.RefreshToken(tokenRequest); + TokenResponse result = await _userService.RefreshToken(tokenRequest) + .ConfigureAwait(false); if (!result.IsError) return Ok(result.Json); return Conflict(result.Json); @@ -88,7 +91,8 @@ public async Task> RevokeToken([FromBody] { try { - TokenRevocationResponse result = await _userService.RevokeToken(tokenRequest); + TokenRevocationResponse result = await _userService.RevokeToken(tokenRequest) + .ConfigureAwait(false); if (!result.IsError) return Ok(); return Conflict(result.Json);