Fixing sonarcloud issues
This commit is contained in:
@@ -53,4 +53,4 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,4 +74,4 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
|
||||
#nullable disable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,9 +67,9 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
if (await this._roleService.CheckIfNameIsValid(request.Data.Name))
|
||||
if (await this._roleService.CheckIfNameIsValid(request!.Data!.Name))
|
||||
{
|
||||
var role = await this._roleService.CreateRoleAsync(request.Data);
|
||||
var role = await this._roleService.CreateRoleAsync(request!.Data);
|
||||
|
||||
if (role == null || String.IsNullOrEmpty(role.Guid))
|
||||
{
|
||||
@@ -121,8 +121,8 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
}
|
||||
|
||||
if (
|
||||
await this._roleService.CheckIfNameIsValid(request.Data.Name) ||
|
||||
await this._roleService.CheckIfNameIsValid(request.Data.Name, guid)
|
||||
await this._roleService.CheckIfNameIsValid(request!.Data!.Name) ||
|
||||
await this._roleService.CheckIfNameIsValid(request!.Data!.Name, guid)
|
||||
)
|
||||
{
|
||||
role = await this._roleService.UpdateRoleAsync(request.Data, role);
|
||||
@@ -167,7 +167,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
await this._roleService.DeleteRoleAsync(role);
|
||||
await this._roleService.DeleteRoleAsync(role);
|
||||
|
||||
return Success(String.Empty);
|
||||
}
|
||||
@@ -185,4 +185,4 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,4 +15,4 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
this._userService = userService;
|
||||
this._roleService = roleService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[JwtAuthorization()]
|
||||
[ModelStateValidationHandledByFilterAttribute]
|
||||
@@ -73,13 +73,13 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
{
|
||||
if (await this._userService.CheckIfEmailIsValid(request!.Data!.Email))
|
||||
{
|
||||
var role = await this._roleService.GetRoleForUser(request.Data.RoleGuid);
|
||||
var role = await this._roleService.GetRoleForUser(request!.Data!.RoleGuid);
|
||||
if (role == null)
|
||||
{
|
||||
return BadRequest("Role not found");
|
||||
}
|
||||
|
||||
var user = await this._userService.CreateUserAsync(request.Data, role);
|
||||
var user = await this._userService.CreateUserAsync(request!.Data, role);
|
||||
|
||||
if (user == null || String.IsNullOrEmpty(user.Guid))
|
||||
{
|
||||
@@ -119,7 +119,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
try
|
||||
{
|
||||
var user = await this._userService.GetUserByGuidAsync(guid);
|
||||
if(user == null)
|
||||
if (user == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
@@ -129,7 +129,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
var userDto = _mapper?.Map<UserDto>(user);
|
||||
|
||||
return Success(String.Empty, userDto);
|
||||
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@@ -141,7 +141,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
return InternalServerError(message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[JwtAuthorization()]
|
||||
[ModelStateValidationHandledByFilterAttribute]
|
||||
@@ -154,7 +154,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
try
|
||||
{
|
||||
var user = await this._userService.GetUserByGuidAsync(guid);
|
||||
if(user == null)
|
||||
if (user == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
@@ -164,7 +164,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
var userDto = _mapper?.Map<UserDto>(user);
|
||||
|
||||
return Success(String.Empty, userDto);
|
||||
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@@ -176,7 +176,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
return InternalServerError(message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[JwtAuthorization()]
|
||||
[ModelStateValidationHandledByFilterAttribute]
|
||||
@@ -195,7 +195,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
}
|
||||
|
||||
var user = await this._userService.GetUserByGuidAsync(guid);
|
||||
if(user == null)
|
||||
if (user == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
@@ -205,7 +205,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
var userDto = _mapper?.Map<UserDto>(user);
|
||||
|
||||
return Success(String.Empty, userDto);
|
||||
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@@ -217,8 +217,8 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
return InternalServerError(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[JwtAuthorization()]
|
||||
[ModelStateValidationHandledByFilterAttribute]
|
||||
[HttpDelete("{guid}")]
|
||||
@@ -239,7 +239,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
|
||||
await this._userService.DeleteUserAsync(user);
|
||||
|
||||
return Success(String.Empty);
|
||||
return Success(String.Empty);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@@ -254,4 +254,4 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,4 +16,4 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
||||
return Success(String.Empty, _appSettings?.Settings?.Version);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,4 @@ namespace BasicDotnetTemplate.MainProject.Core.Attributes
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
|
||||
public class ModelStateValidationHandledByFilterAttribute : Attribute
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace BasicDotnetTemplate.MainProject.Core.Database
|
||||
public DbSet<PermissionOperation> PermissionOperations { get; set; }
|
||||
public DbSet<PermissionSystem> PermissionSystems { get; set; }
|
||||
public DbSet<PermissionSystemModule> PermissionSystemModules { get; set; }
|
||||
public DbSet<PermissionSystemModuleOperation> PermissionSystemModuleOperations { get; set; }
|
||||
public DbSet<PermissionSystemModuleOperation> PermissionSystemModuleOperations { get; set; }
|
||||
public DbSet<RolePermissionSystemModuleOperation> RolePermissionSystemModuleOperations { get; set; }
|
||||
public DbSet<Role> Roles { get; set; }
|
||||
public DbSet<User> Users { get; set; }
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace BasicDotnetTemplate.MainProject.Core.Filters
|
||||
if (!context.ModelState.IsValid)
|
||||
{
|
||||
context.Result = new BadRequestObjectResult(new { message = _requestNotWellFormedMessage, errors = context.ModelState });
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
var requestBody = context.ActionArguments.Values.FirstOrDefault(arg => arg != null && !arg.GetType().IsPrimitive && !(arg is string));
|
||||
@@ -27,4 +27,4 @@ namespace BasicDotnetTemplate.MainProject.Core.Filters
|
||||
await next();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ public class UserRole
|
||||
public string? Name { get; set; }
|
||||
#nullable disable
|
||||
|
||||
public UserRole() {}
|
||||
public UserRole() { }
|
||||
|
||||
public UserRole(DatabaseSqlServer.Role role)
|
||||
{
|
||||
|
||||
@@ -8,4 +8,4 @@ public class CreateRoleRequestData
|
||||
public required string Name { get; set; }
|
||||
public required bool IsNotEditable { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,4 @@ public class CreateRoleRequest
|
||||
#nullable enable
|
||||
public CreateRoleRequestData? Data { get; set; }
|
||||
#nullable disable
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,4 +5,4 @@ namespace BasicDotnetTemplate.MainProject.Models.Api.Response.Auth;
|
||||
public class AuthenticateResponse : BaseResponse<AuthenticatedUser>
|
||||
{
|
||||
public AuthenticateResponse(int status, string? message, AuthenticatedUser? data) : base(status, message, data) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,4 +16,4 @@ public class BaseResponse<T>
|
||||
|
||||
public virtual dynamic? Data { get; set; }
|
||||
#nullable disable
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,4 +5,4 @@ namespace BasicDotnetTemplate.MainProject.Models.Api.Response.Role;
|
||||
public class GetRoleResponse : BaseResponse<RoleDto>
|
||||
{
|
||||
public GetRoleResponse(int status, string? message, RoleDto? data) : base(status, message, data) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,4 +5,4 @@ namespace BasicDotnetTemplate.MainProject.Models.Api.Response.User;
|
||||
public class GetUserResponse : BaseResponse<UserDto>
|
||||
{
|
||||
public GetUserResponse(int status, string? message, UserDto? data) : base(status, message, data) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ public class OperationInfo
|
||||
{
|
||||
#nullable enable
|
||||
public string? Operation { get; set; }
|
||||
public List<string>? Roles {get; set; }
|
||||
public List<string>? Roles { get; set; }
|
||||
#nullable disable
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ public class PermissionInfo
|
||||
{
|
||||
#nullable enable
|
||||
public string? System { get; set; }
|
||||
public List<RolePermissionModuleOperation>? RolePermissionModuleOperations {get; set; }
|
||||
public List<RolePermissionModuleOperation>? RolePermissionModuleOperations { get; set; }
|
||||
#nullable disable
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,4 +5,4 @@ public class PermissionsFile
|
||||
#nullable enable
|
||||
public List<PermissionInfo>? PermissionInfos { get; set; }
|
||||
#nullable disable
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,4 +6,4 @@ public class RolePermissionModuleOperation
|
||||
public string? Module { get; set; }
|
||||
public List<OperationInfo>? Operations { get; set; }
|
||||
#nullable disable
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@ namespace BasicDotnetTemplate.MainProject.Models.Database.Mongo
|
||||
[BsonId]
|
||||
public ObjectId Id { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@ namespace BasicDotnetTemplate.MainProject.Models.Database.SqlServer
|
||||
public required string Name { get; set; }
|
||||
public required bool Enabled { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,4 @@ namespace BasicDotnetTemplate.MainProject.Models.Database.SqlServer
|
||||
[MaxLength(100)]
|
||||
public required string Name { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@ namespace BasicDotnetTemplate.MainProject.Models.Database.SqlServer
|
||||
public required string Name { get; set; }
|
||||
public required bool Enabled { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,4 +10,4 @@ namespace BasicDotnetTemplate.MainProject.Models.Database.SqlServer
|
||||
public required PermissionModule PermissionModule { get; set; }
|
||||
public required bool Enabled { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,4 +10,4 @@ namespace BasicDotnetTemplate.MainProject.Models.Database.SqlServer
|
||||
public required PermissionSystemModule PermissionSystemModule { get; set; }
|
||||
public required PermissionOperation PermissionOperation { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,4 +10,4 @@ namespace BasicDotnetTemplate.MainProject.Models.Database.SqlServer
|
||||
public required Role Role { get; set; }
|
||||
public required PermissionSystemModuleOperation PermissionSystemModuleOperation { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,4 @@ public class AppSettings
|
||||
public EncryptionSettings? EncryptionSettings { get; set; }
|
||||
public PermissionsSettings? PermissionsSettings { get; set; }
|
||||
#nullable disable
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,4 @@ public class DatabaseConnection
|
||||
public string? Postgres { get; set; }
|
||||
public string? Mongodb { get; set; }
|
||||
#nullable disable
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,4 @@ public class DatabaseSettings
|
||||
public string? MongoDbConnectionString { get; set; }
|
||||
public string? PostgreSQLConnectionString { get; set; }
|
||||
#nullable disable
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,4 @@ public class EncryptionSettings
|
||||
public string? Salt { get; set; }
|
||||
public int? Iterations { get; set; }
|
||||
#nullable disable
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,4 @@ public class JwtSettings
|
||||
public int? ExpiredAfterMinsOfInactivity { get; set; }
|
||||
|
||||
#nullable disable
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,4 @@ public class OpenApiSettings
|
||||
public OpenApiSettingsDetails? OpenApiContact { get; set; }
|
||||
public OpenApiSettingsDetails? OpenApiLicense { get; set; }
|
||||
#nullable disable
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,4 +6,4 @@ public class OpenApiSettingsDetails
|
||||
public string? Name { get; set; }
|
||||
public string? Url { get; set; }
|
||||
#nullable disable
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,4 +5,4 @@ public class PermissionsSettings
|
||||
#nullable enable
|
||||
public string? FilePath { get; set; }
|
||||
#nullable disable
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,4 +5,4 @@ public class PrivateSettings
|
||||
#nullable enable
|
||||
public DatabaseConnection? DatabaseConnection { get; set; }
|
||||
#nullable disable
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,4 @@ public class Settings
|
||||
public string? Version { get; set; }
|
||||
public string? Description { get; set; }
|
||||
#nullable disable
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using NLog;
|
||||
using NLog;
|
||||
using BasicDotnetTemplate.MainProject.Models.Settings;
|
||||
using System.Reflection;
|
||||
using BasicDotnetTemplate.MainProject.Utils;
|
||||
@@ -60,4 +60,4 @@ internal static class Program
|
||||
NLog.LogManager.Shutdown(); // Flush and close down internal threads and timers
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1275,4 +1275,4 @@ public class PermissionService : BaseService, IPermissionService
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ public class UserService : BaseService, IUserService
|
||||
|
||||
user.PasswordSalt = salt;
|
||||
user.PasswordPepper = pepper;
|
||||
user.PasswordIterations = iterations;
|
||||
user.PasswordIterations = iterations;
|
||||
user.Password = CryptUtils.GeneratePassword(newPassword, salt, iterations, pepper);
|
||||
user.UpdateTime = DateTime.UtcNow;
|
||||
user.UpdateUserId = this.GetCurrentUserId();
|
||||
|
||||
@@ -39,4 +39,4 @@ public static class FileUtils
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public static partial class PasswordUtils
|
||||
private static partial Regex RegexSpecial();
|
||||
|
||||
private static readonly Regex RegexIdenticalChars = new(
|
||||
@"(\S)\1{2,}",
|
||||
@"(\S)\1{2,}",
|
||||
RegexOptions.IgnoreCase | RegexOptions.Compiled,
|
||||
TimeSpan.FromMilliseconds(100)
|
||||
);
|
||||
|
||||
@@ -142,7 +142,7 @@ public static class ProgramUtils
|
||||
builder.Services.AddAuthorization();
|
||||
builder.Services.AddControllers(options =>
|
||||
{
|
||||
options.Filters.Add<ValidationActionFilter>();
|
||||
options.Filters.Add<ValidationActionFilter>();
|
||||
});
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
|
||||
@@ -295,4 +295,4 @@ public static class ProgramUtils
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user