diff options
| author | transtrike <transtrike@gmail.com> | 2021-02-13 18:36:25 +0200 |
|---|---|---|
| committer | transtrike <transtrike@gmail.com> | 2021-02-13 18:36:25 +0200 |
| commit | 018e9d303c38407589f06ec37a4a72dc4ce8e3b4 (patch) | |
| tree | 05387c66338796a4c207c3bcbeca454329a28120 /src/Services | |
| parent | d9b9685204ece098df5a2425246a10bf65004b0f (diff) | |
| download | DevHive-018e9d303c38407589f06ec37a4a72dc4ce8e3b4.tar DevHive-018e9d303c38407589f06ec37a4a72dc4ce8e3b4.tar.gz DevHive-018e9d303c38407589f06ec37a4a72dc4ce8e3b4.zip | |
Merged New Project Structure; Fixed Kamen's Formatting Issues
Diffstat (limited to 'src/Services')
4 files changed, 28 insertions, 28 deletions
diff --git a/src/Services/DevHive.Services/Interfaces/IPostService.cs b/src/Services/DevHive.Services/Interfaces/IPostService.cs index d35acfd..5ccecff 100644 --- a/src/Services/DevHive.Services/Interfaces/IPostService.cs +++ b/src/Services/DevHive.Services/Interfaces/IPostService.cs @@ -4,7 +4,7 @@ using DevHive.Services.Models.Post; namespace DevHive.Services.Interfaces { - public interface IPostService + public interface IPostService { Task<Guid> CreatePost(CreatePostServiceModel createPostServiceModel); diff --git a/src/Services/DevHive.Services/Services/FeedService.cs b/src/Services/DevHive.Services/Services/FeedService.cs index a0f1f1b..5feef6e 100644 --- a/src/Services/DevHive.Services/Services/FeedService.cs +++ b/src/Services/DevHive.Services/Services/FeedService.cs @@ -27,7 +27,7 @@ namespace DevHive.Services.Services /// <summary> /// This method is used in the feed page. /// See the FeedRepository "GetFriendsPosts" menthod for more information on how it works. - /// </summary> + /// </summary> public async Task<ReadPageServiceModel> GetPage(GetPageServiceModel model) { User user = null; @@ -58,7 +58,7 @@ namespace DevHive.Services.Services /// <summary> /// This method is used in the profile pages. /// See the FeedRepository "GetUsersPosts" menthod for more information on how it works. - /// </summary> + /// </summary> public async Task<ReadPageServiceModel> GetUserPage(GetPageServiceModel model) { User user = null; diff --git a/src/Services/DevHive.Services/Services/PostService.cs b/src/Services/DevHive.Services/Services/PostService.cs index c368ce6..0becd9f 100644 --- a/src/Services/DevHive.Services/Services/PostService.cs +++ b/src/Services/DevHive.Services/Services/PostService.cs @@ -13,7 +13,7 @@ using DevHive.Data.Models.Relational; namespace DevHive.Services.Services { - public class PostService : IPostService + public class PostService : IPostService { private readonly ICloudService _cloudService; private readonly IUserRepository _userRepository; @@ -144,8 +144,8 @@ namespace DevHive.Services.Services #region Validations /// <summary> - /// Checks whether the user Id in the token and the given user Id match - /// </summary> + /// Checks whether the user Id in the token and the given user Id match + /// </summary> public async Task<bool> ValidateJwtForCreating(Guid userId, string rawTokenData) { User user = await this.GetUserForValidation(rawTokenData); @@ -154,10 +154,10 @@ namespace DevHive.Services.Services } /// <summary> - /// Checks whether the post, gotten with the postId, + /// Checks whether the post, gotten with the postId, /// is made by the user in the token /// or if the user in the token is an admin - /// </summary> + /// </summary> public async Task<bool> ValidateJwtForPost(Guid postId, string rawTokenData) { Post post = await this._postRepository.GetByIdAsync(postId) ?? @@ -175,10 +175,10 @@ namespace DevHive.Services.Services } /// <summary> - /// Checks whether the comment, gotten with the commentId, + /// 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 - /// </summary> + /// </summary> public async Task<bool> ValidateJwtForComment(Guid commentId, string rawTokenData) { Comment comment = await this._commentRepository.GetByIdAsync(commentId) ?? @@ -196,8 +196,8 @@ namespace DevHive.Services.Services } /// <summary> - /// Returns the user, via their Id in the token - /// </summary> + /// Returns the user, via their Id in the token + /// </summary> private async Task<User> GetUserForValidation(string rawTokenData) { JwtSecurityToken jwt = new JwtSecurityTokenHandler().ReadJwtToken(rawTokenData.Remove(0, 7)); @@ -212,8 +212,8 @@ namespace DevHive.Services.Services } /// <summary> - /// Returns all values from a given claim type - /// </summary> + /// Returns all values from a given claim type + /// </summary> private List<string> GetClaimTypeValues(string type, IEnumerable<Claim> claims) { List<string> toReturn = new(); diff --git a/src/Services/DevHive.Services/Services/UserService.cs b/src/Services/DevHive.Services/Services/UserService.cs index f2c5a5b..9a63853 100644 --- a/src/Services/DevHive.Services/Services/UserService.cs +++ b/src/Services/DevHive.Services/Services/UserService.cs @@ -54,9 +54,9 @@ namespace DevHive.Services.Services #region Authentication /// <summary> - /// Adds a new user to the database with the values from the given model. + /// Adds a new user to the database with the values from the given model. /// Returns a JSON Web Token (that can be used for authorization) - /// </summary> + /// </summary> public async Task<TokenModel> LoginUser(LoginServiceModel loginModel) { if (!await this._userRepository.DoesUsernameExistAsync(loginModel.UserName)) @@ -71,8 +71,8 @@ namespace DevHive.Services.Services } /// <summary> - /// Returns a new JSON Web Token (that can be used for authorization) for the given user - /// </summary> + /// Returns a new JSON Web Token (that can be used for authorization) for the given user + /// </summary> public async Task<TokenModel> RegisterUser(RegisterServiceModel registerModel) { if (await this._userRepository.DoesUsernameExistAsync(registerModel.UserName)) @@ -143,8 +143,8 @@ namespace DevHive.Services.Services } /// <summary> - /// Uploads the given picture and assigns it's link to the user in the database - /// </summary> + /// Uploads the given picture and assigns it's link to the user in the database + /// </summary> public async Task<ProfilePictureServiceModel> UpdateProfilePicture(UpdateProfilePictureServiceModel updateProfilePictureServiceModel) { User user = await this._userRepository.GetByIdAsync(updateProfilePictureServiceModel.UserId); @@ -183,10 +183,10 @@ namespace DevHive.Services.Services #region Validations /// <summary> - /// Checks whether the given user, gotten by the "id" property, + /// Checks whether the given user, gotten by the "id" property, /// is the same user as the one in the token (uness the user in the token has the admin role) /// and the roles in the token are the same as those in the user, gotten by the id in the token - /// </summary> + /// </summary> public async Task<bool> ValidJWT(Guid id, string rawTokenData) { // There is authorization name in the beginning, i.e. "Bearer eyJh..." @@ -220,8 +220,8 @@ namespace DevHive.Services.Services } /// <summary> - /// Returns all values from a given claim type - /// </summary> + /// Returns all values from a given claim type + /// </summary> private List<string> GetClaimTypeValues(string type, IEnumerable<Claim> claims) { List<string> toReturn = new(); @@ -234,10 +234,10 @@ namespace DevHive.Services.Services } /// <summary> - /// Checks whether the user in the model exists + /// Checks whether the user in the model exists /// and whether the username in the model is already taken. /// If the check fails (is false), it throws an exception, otherwise nothing happens - /// </summary> + /// </summary> private async Task ValidateUserOnUpdate(UpdateUserServiceModel updateUserServiceModel) { if (!await this._userRepository.DoesUserExistAsync(updateUserServiceModel.Id)) @@ -259,9 +259,9 @@ namespace DevHive.Services.Services } /// <summary> - /// Return a new JSON Web Token, containing the user id, username and roles. + /// Return a new JSON Web Token, containing the user id, username and roles. /// Tokens have an expiration time of 7 days. - /// </summary> + /// </summary> private string WriteJWTSecurityToken(Guid userId, string username, HashSet<Role> roles) { byte[] signingKey = Encoding.ASCII.GetBytes(_jwtOptions.Secret); |
