From 8e09ab34b54718af7753ba7d7e4e370ab14efa1a Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 4 Feb 2021 15:31:49 +0200 Subject: Added some XML documentation to Service layer (where really needed) --- src/DevHive.Services/Services/CommentService.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/DevHive.Services/Services/CommentService.cs') diff --git a/src/DevHive.Services/Services/CommentService.cs b/src/DevHive.Services/Services/CommentService.cs index e0eb88a..1ea775c 100644 --- a/src/DevHive.Services/Services/CommentService.cs +++ b/src/DevHive.Services/Services/CommentService.cs @@ -103,6 +103,9 @@ namespace DevHive.Services.Services #endregion #region Validations + /// + /// Checks whether the user Id in the token and the given user Id match + /// public async Task ValidateJwtForCreating(Guid userId, string rawTokenData) { User user = await this.GetUserForValidation(rawTokenData); @@ -110,6 +113,11 @@ namespace DevHive.Services.Services return user.Id == userId; } + /// + /// Checks whether the comment, gotten with the commentId, + /// is made by the user in the token + /// or if the user in the token is an admin + /// public async Task ValidateJwtForComment(Guid commentId, string rawTokenData) { Comment comment = await this._commentRepository.GetByIdAsync(commentId) ?? @@ -126,6 +134,9 @@ namespace DevHive.Services.Services return false; } + /// + /// Returns the user, via their Id in the token + /// private async Task GetUserForValidation(string rawTokenData) { JwtSecurityToken jwt = new JwtSecurityTokenHandler().ReadJwtToken(rawTokenData.Remove(0, 7)); @@ -139,7 +150,9 @@ namespace DevHive.Services.Services return user; } - + /// + /// Returns all values from a given claim type + /// private List GetClaimTypeValues(string type, IEnumerable claims) { List toReturn = new(); -- cgit v1.2.3