From 5a62952229d784bab73260c6ff76b8d25500bbb4 Mon Sep 17 00:00:00 2001 From: transtrike Date: Thu, 14 Jan 2021 09:40:55 +0200 Subject: Renamed async methods to include Async in the name in UserRepository --- src/DevHive.Services/Services/PostService.cs | 6 +++--- src/DevHive.Services/Services/UserService.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/DevHive.Services') diff --git a/src/DevHive.Services/Services/PostService.cs b/src/DevHive.Services/Services/PostService.cs index da9e76b..24ca8f3 100644 --- a/src/DevHive.Services/Services/PostService.cs +++ b/src/DevHive.Services/Services/PostService.cs @@ -101,7 +101,7 @@ namespace DevHive.Services.Services return result; } - //Validate + //Validate public async Task ValidateJwtForComment(Guid commentId, string rawTokenData) { Comment comment = await this._postRepository.GetCommentByIdAsync(commentId); @@ -120,7 +120,7 @@ namespace DevHive.Services.Services string jwtUserName = this.GetClaimTypeValues("unique_name", jwt.Claims)[0]; //List jwtRoleNames = this.GetClaimTypeValues("role", jwt.Claims); - User user = await this._userRepository.GetByUsername(jwtUserName) + User user = await this._userRepository.GetByUsernameAsync(jwtUserName) ?? throw new ArgumentException("User does not exist!"); return user; @@ -137,4 +137,4 @@ namespace DevHive.Services.Services return toReturn; } } -} \ No newline at end of file +} diff --git a/src/DevHive.Services/Services/UserService.cs b/src/DevHive.Services/Services/UserService.cs index 012ec1b..44cb0e2 100644 --- a/src/DevHive.Services/Services/UserService.cs +++ b/src/DevHive.Services/Services/UserService.cs @@ -50,7 +50,7 @@ namespace DevHive.Services.Services if (!await this._userRepository.DoesUsernameExistAsync(loginModel.UserName)) throw new ArgumentException("Invalid username!"); - User user = await this._userRepository.GetByUsername(loginModel.UserName); + User user = await this._userRepository.GetByUsernameAsync(loginModel.UserName); if (user.PasswordHash != GeneratePasswordHash(loginModel.Password)) throw new ArgumentException("Incorrect password!"); @@ -276,7 +276,7 @@ namespace DevHive.Services.Services string jwtUserName = this.GetClaimTypeValues("unique_name", jwt.Claims)[0]; List jwtRoleNames = this.GetClaimTypeValues("role", jwt.Claims); - User user = await this._userRepository.GetByUsername(jwtUserName) + User user = await this._userRepository.GetByUsernameAsync(jwtUserName) ?? throw new ArgumentException("User does not exist!"); /* Username check, only when user isn't admin */ -- cgit v1.2.3