modif + Bcrypt
This commit is contained in:
Generated
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||||
<data-source source="LOCAL" name="@romaric-thibault.fr" uuid="6e1760b6-e554-4516-9799-154d6f998f71">
|
<data-source source="LOCAL" name="@romaric-thibault.fr" uuid="821fc51f-62ea-4fa2-99b3-cb667f09e32a">
|
||||||
<driver-ref>sqlserver.jb</driver-ref>
|
<driver-ref>sqlserver.jb</driver-ref>
|
||||||
<synchronize>true</synchronize>
|
<synchronize>true</synchronize>
|
||||||
<jdbc-driver>com.jetbrains.jdbc.sqlserver.SqlServerDriver</jdbc-driver>
|
<jdbc-driver>com.jetbrains.jdbc.sqlserver.SqlServerDriver</jdbc-driver>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Knots.DTO.User;
|
using Knots.DTO.User;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace Knots.Endpoints.User;
|
namespace Knots.Endpoints.User;
|
||||||
|
|
||||||
@@ -13,6 +14,17 @@ public class CreateUserEndpoint(KnotsDbContext db, AutoMapper.IMapper mapper) :
|
|||||||
|
|
||||||
public override async Task HandleAsync(CreateUserDto req, CancellationToken ct)
|
public override async Task HandleAsync(CreateUserDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
|
bool usernameExists = await db.Users
|
||||||
|
.AnyAsync(x => x.Username == req.Username, cancellationToken: ct);
|
||||||
|
|
||||||
|
if (usernameExists)
|
||||||
|
{
|
||||||
|
AddError(x => x.Username, "Ce nom d'utilisateur est déjà pris.");
|
||||||
|
await Send.ErrorsAsync(cancellation: ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Password = BCrypt.Net.BCrypt.HashPassword(req.Password);
|
||||||
Models.User? user = mapper.Map<Models.User>(req);
|
Models.User? user = mapper.Map<Models.User>(req);
|
||||||
db.Users.Add(user);
|
db.Users.Add(user);
|
||||||
await db.SaveChangesAsync(ct);
|
await db.SaveChangesAsync(ct);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class LoginEndpoint(KnotsDbContext db, JwtService jwtService) : Endpoint<
|
|||||||
Models.User? user = await db.Users
|
Models.User? user = await db.Users
|
||||||
.SingleOrDefaultAsync(x => x.Username == req.Username, cancellationToken: ct);
|
.SingleOrDefaultAsync(x => x.Username == req.Username, cancellationToken: ct);
|
||||||
|
|
||||||
if (user is null || user.Password != req.Password) // hash à ajouter plus tard
|
if (user is null || !BCrypt.Net.BCrypt.Verify(req.Password, user.Password)) // hash à ajouter plus tard
|
||||||
{
|
{
|
||||||
await Send.UnauthorizedAsync(ct);
|
await Send.UnauthorizedAsync(ct);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AutoMapper" Version="16.1.1" />
|
<PackageReference Include="AutoMapper" Version="16.1.1" />
|
||||||
|
<PackageReference Include="BCrypt.Net-Next" Version="4.2.0" />
|
||||||
<PackageReference Include="FastEndpoints" Version="8.0.1" />
|
<PackageReference Include="FastEndpoints" Version="8.0.1" />
|
||||||
<PackageReference Include="FastEndpoints.Swagger" Version="8.0.1" />
|
<PackageReference Include="FastEndpoints.Swagger" Version="8.0.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.3.11" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.3.11" />
|
||||||
|
|||||||
Binary file not shown.
@@ -9,6 +9,7 @@
|
|||||||
"Knots/1.0.0": {
|
"Knots/1.0.0": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"AutoMapper": "16.1.1",
|
"AutoMapper": "16.1.1",
|
||||||
|
"BCrypt.Net-Next": "4.2.0",
|
||||||
"FastEndpoints": "8.0.1",
|
"FastEndpoints": "8.0.1",
|
||||||
"FastEndpoints.Swagger": "8.0.1",
|
"FastEndpoints.Swagger": "8.0.1",
|
||||||
"Microsoft.AspNetCore.Authentication": "2.3.11",
|
"Microsoft.AspNetCore.Authentication": "2.3.11",
|
||||||
@@ -71,6 +72,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"BCrypt.Net-Next/4.2.0": {
|
||||||
|
"runtime": {
|
||||||
|
"lib/netstandard2.1/BCrypt-Net-Next.dll": {
|
||||||
|
"assemblyVersion": "4.2.0.0",
|
||||||
|
"fileVersion": "4.2.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"FastEndpoints/8.0.1": {
|
"FastEndpoints/8.0.1": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"FastEndpoints.Attributes": "8.0.1",
|
"FastEndpoints.Attributes": "8.0.1",
|
||||||
@@ -1437,6 +1446,13 @@
|
|||||||
"path": "azure.identity/1.11.4",
|
"path": "azure.identity/1.11.4",
|
||||||
"hashPath": "azure.identity.1.11.4.nupkg.sha512"
|
"hashPath": "azure.identity.1.11.4.nupkg.sha512"
|
||||||
},
|
},
|
||||||
|
"BCrypt.Net-Next/4.2.0": {
|
||||||
|
"type": "package",
|
||||||
|
"serviceable": true,
|
||||||
|
"sha512": "sha512-gwLD2KfCuwQesP17aVh4h6lpiMPEVt5Lbpndo0ej903hNUUTtyxt3ARdDjmuydBRTAUICc7OVKVbaOvc6SQYXA==",
|
||||||
|
"path": "bcrypt.net-next/4.2.0",
|
||||||
|
"hashPath": "bcrypt.net-next.4.2.0.nupkg.sha512"
|
||||||
|
},
|
||||||
"FastEndpoints/8.0.1": {
|
"FastEndpoints/8.0.1": {
|
||||||
"type": "package",
|
"type": "package",
|
||||||
"serviceable": true,
|
"serviceable": true,
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Knots")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("Knots")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+e8d5ac797b67a6c7c6719e831ac1f150893f28ad")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+84d0376138f9f289ef91e21fdd18b25c871c1acf")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("Knots")]
|
[assembly: System.Reflection.AssemblyProductAttribute("Knots")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("Knots")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("Knots")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
f590fd7039e5e02a09290e867dcff1d085dc86bbc598b2bf76d4d65ccda866ca
|
3f7b2a3ee7c375b1158b1a88381cf4975972813f9f9a5febadee3fc42d938a09
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
|||||||
c63bb86637486085df3f28dc9ab57c639ae176fe7083ba40d0795948620e0a00
|
bb48158ec8eb2df7ad212aee65554da457917fda1961b2e4475621e399c96301
|
||||||
|
|||||||
@@ -348,3 +348,4 @@ C:\Users\Carte\RiderProjects\Knots\Knots\bin\Debug\net8.0\Microsoft.Extensions.W
|
|||||||
C:\Users\Carte\RiderProjects\Knots\Knots\bin\Debug\net8.0\System.Security.Cryptography.Pkcs.dll
|
C:\Users\Carte\RiderProjects\Knots\Knots\bin\Debug\net8.0\System.Security.Cryptography.Pkcs.dll
|
||||||
C:\Users\Carte\RiderProjects\Knots\Knots\bin\Debug\net8.0\System.Security.Cryptography.Xml.dll
|
C:\Users\Carte\RiderProjects\Knots\Knots\bin\Debug\net8.0\System.Security.Cryptography.Xml.dll
|
||||||
C:\Users\Carte\RiderProjects\Knots\Knots\bin\Debug\net8.0\runtimes\win\lib\net8.0\System.Security.Cryptography.Pkcs.dll
|
C:\Users\Carte\RiderProjects\Knots\Knots\bin\Debug\net8.0\runtimes\win\lib\net8.0\System.Security.Cryptography.Pkcs.dll
|
||||||
|
C:\Users\Carte\RiderProjects\Knots\Knots\bin\Debug\net8.0\BCrypt-Net-Next.dll
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -53,6 +53,10 @@
|
|||||||
"target": "Package",
|
"target": "Package",
|
||||||
"version": "[16.1.1, )"
|
"version": "[16.1.1, )"
|
||||||
},
|
},
|
||||||
|
"BCrypt.Net-Next": {
|
||||||
|
"target": "Package",
|
||||||
|
"version": "[4.2.0, )"
|
||||||
|
},
|
||||||
"FastEndpoints": {
|
"FastEndpoints": {
|
||||||
"target": "Package",
|
"target": "Package",
|
||||||
"version": "[8.0.1, )"
|
"version": "[8.0.1, )"
|
||||||
|
|||||||
@@ -65,6 +65,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"BCrypt.Net-Next/4.2.0": {
|
||||||
|
"type": "package",
|
||||||
|
"compile": {
|
||||||
|
"lib/netstandard2.1/BCrypt-Net-Next.dll": {}
|
||||||
|
},
|
||||||
|
"runtime": {
|
||||||
|
"lib/netstandard2.1/BCrypt-Net-Next.dll": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
"FastEndpoints/8.0.1": {
|
"FastEndpoints/8.0.1": {
|
||||||
"type": "package",
|
"type": "package",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -2416,6 +2425,31 @@
|
|||||||
"lib/netstandard2.0/Azure.Identity.xml"
|
"lib/netstandard2.0/Azure.Identity.xml"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"BCrypt.Net-Next/4.2.0": {
|
||||||
|
"sha512": "gwLD2KfCuwQesP17aVh4h6lpiMPEVt5Lbpndo0ej903hNUUTtyxt3ARdDjmuydBRTAUICc7OVKVbaOvc6SQYXA==",
|
||||||
|
"type": "package",
|
||||||
|
"path": "bcrypt.net-next/4.2.0",
|
||||||
|
"files": [
|
||||||
|
".nupkg.metadata",
|
||||||
|
".signature.p7s",
|
||||||
|
"bcrypt.net-next.4.2.0.nupkg.sha512",
|
||||||
|
"bcrypt.net-next.nuspec",
|
||||||
|
"ico.png",
|
||||||
|
"lib/net10.0/BCrypt-Net-Next.dll",
|
||||||
|
"lib/net10.0/BCrypt.Net-Next.xml",
|
||||||
|
"lib/net462/BCrypt-Net-Next.dll",
|
||||||
|
"lib/net462/BCrypt.Net-Next.xml",
|
||||||
|
"lib/net472/BCrypt-Net-Next.dll",
|
||||||
|
"lib/net472/BCrypt.Net-Next.xml",
|
||||||
|
"lib/net48/BCrypt-Net-Next.dll",
|
||||||
|
"lib/net48/BCrypt.Net-Next.xml",
|
||||||
|
"lib/netstandard2.0/BCrypt-Net-Next.dll",
|
||||||
|
"lib/netstandard2.0/BCrypt.Net-Next.xml",
|
||||||
|
"lib/netstandard2.1/BCrypt-Net-Next.dll",
|
||||||
|
"lib/netstandard2.1/BCrypt.Net-Next.xml",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
|
},
|
||||||
"FastEndpoints/8.0.1": {
|
"FastEndpoints/8.0.1": {
|
||||||
"sha512": "v77ZGHBE95gGCQxDz2mwLNpU42dcD6WPQTpzhnLq8weFHD7mtzhhWgpxaNHt6fYEES/bnYUVzoc4x9QnwDy7Yg==",
|
"sha512": "v77ZGHBE95gGCQxDz2mwLNpU42dcD6WPQTpzhnLq8weFHD7mtzhhWgpxaNHt6fYEES/bnYUVzoc4x9QnwDy7Yg==",
|
||||||
"type": "package",
|
"type": "package",
|
||||||
@@ -5684,6 +5718,7 @@
|
|||||||
"projectFileDependencyGroups": {
|
"projectFileDependencyGroups": {
|
||||||
"net8.0": [
|
"net8.0": [
|
||||||
"AutoMapper >= 16.1.1",
|
"AutoMapper >= 16.1.1",
|
||||||
|
"BCrypt.Net-Next >= 4.2.0",
|
||||||
"FastEndpoints >= 8.0.1",
|
"FastEndpoints >= 8.0.1",
|
||||||
"FastEndpoints.Swagger >= 8.0.1",
|
"FastEndpoints.Swagger >= 8.0.1",
|
||||||
"Microsoft.AspNetCore.Authentication >= 2.3.11",
|
"Microsoft.AspNetCore.Authentication >= 2.3.11",
|
||||||
@@ -5748,6 +5783,10 @@
|
|||||||
"target": "Package",
|
"target": "Package",
|
||||||
"version": "[16.1.1, )"
|
"version": "[16.1.1, )"
|
||||||
},
|
},
|
||||||
|
"BCrypt.Net-Next": {
|
||||||
|
"target": "Package",
|
||||||
|
"version": "[4.2.0, )"
|
||||||
|
},
|
||||||
"FastEndpoints": {
|
"FastEndpoints": {
|
||||||
"target": "Package",
|
"target": "Package",
|
||||||
"version": "[8.0.1, )"
|
"version": "[8.0.1, )"
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"version": 2,
|
"version": 2,
|
||||||
"dgSpecHash": "jgDZDYo35+E=",
|
"dgSpecHash": "RhsVVzLj7C0=",
|
||||||
"success": true,
|
"success": true,
|
||||||
"projectFilePath": "C:\\Users\\Carte\\RiderProjects\\Knots\\Knots\\Knots.csproj",
|
"projectFilePath": "C:\\Users\\Carte\\RiderProjects\\Knots\\Knots\\Knots.csproj",
|
||||||
"expectedPackageFiles": [
|
"expectedPackageFiles": [
|
||||||
"C:\\Users\\Carte\\.nuget\\packages\\automapper\\16.1.1\\automapper.16.1.1.nupkg.sha512",
|
"C:\\Users\\Carte\\.nuget\\packages\\automapper\\16.1.1\\automapper.16.1.1.nupkg.sha512",
|
||||||
"C:\\Users\\Carte\\.nuget\\packages\\azure.core\\1.38.0\\azure.core.1.38.0.nupkg.sha512",
|
"C:\\Users\\Carte\\.nuget\\packages\\azure.core\\1.38.0\\azure.core.1.38.0.nupkg.sha512",
|
||||||
"C:\\Users\\Carte\\.nuget\\packages\\azure.identity\\1.11.4\\azure.identity.1.11.4.nupkg.sha512",
|
"C:\\Users\\Carte\\.nuget\\packages\\azure.identity\\1.11.4\\azure.identity.1.11.4.nupkg.sha512",
|
||||||
|
"C:\\Users\\Carte\\.nuget\\packages\\bcrypt.net-next\\4.2.0\\bcrypt.net-next.4.2.0.nupkg.sha512",
|
||||||
"C:\\Users\\Carte\\.nuget\\packages\\fastendpoints\\8.0.1\\fastendpoints.8.0.1.nupkg.sha512",
|
"C:\\Users\\Carte\\.nuget\\packages\\fastendpoints\\8.0.1\\fastendpoints.8.0.1.nupkg.sha512",
|
||||||
"C:\\Users\\Carte\\.nuget\\packages\\fastendpoints.attributes\\8.0.1\\fastendpoints.attributes.8.0.1.nupkg.sha512",
|
"C:\\Users\\Carte\\.nuget\\packages\\fastendpoints.attributes\\8.0.1\\fastendpoints.attributes.8.0.1.nupkg.sha512",
|
||||||
"C:\\Users\\Carte\\.nuget\\packages\\fastendpoints.core\\8.0.1\\fastendpoints.core.8.0.1.nupkg.sha512",
|
"C:\\Users\\Carte\\.nuget\\packages\\fastendpoints.core\\8.0.1\\fastendpoints.core.8.0.1.nupkg.sha512",
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
"restore":{"projectUniqueName":"C:\\Users\\Carte\\RiderProjects\\Knots\\Knots\\Knots.csproj","projectName":"Knots","projectPath":"C:\\Users\\Carte\\RiderProjects\\Knots\\Knots\\Knots.csproj","packagesPath":"","outputPath":"C:\\Users\\Carte\\RiderProjects\\Knots\\Knots\\obj\\","projectStyle":"PackageReference","fallbackFolders":["C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"],"originalTargetFrameworks":["net8.0"],"sources":{"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\":{},"https://api.nuget.org/v3/index.json":{}},"frameworks":{"net8.0":{"targetAlias":"net8.0","projectReferences":{}}},"warningProperties":{"warnAsError":["NU1605"]},"restoreAuditProperties":{"enableAudit":"true","auditLevel":"low","auditMode":"direct"}}"frameworks":{"net8.0":{"targetAlias":"net8.0","dependencies":{"AutoMapper":{"target":"Package","version":"[16.1.1, )"},"FastEndpoints":{"target":"Package","version":"[8.0.1, )"},"FastEndpoints.Swagger":{"target":"Package","version":"[8.0.1, )"},"Microsoft.AspNetCore.Authentication":{"target":"Package","version":"[2.3.11, )"},"Microsoft.AspNetCore.Authentication.JwtBearer":{"target":"Package","version":"[8.0.28, )"},"Microsoft.AspNetCore.OpenApi":{"target":"Package","version":"[8.0.25, )"},"Microsoft.EntityFrameworkCore":{"target":"Package","version":"[8.0.25, )"},"Microsoft.EntityFrameworkCore.Design":{"include":"Runtime, Build, Native, ContentFiles, Analyzers, BuildTransitive","suppressParent":"All","target":"Package","version":"[8.0.25, )"},"Microsoft.EntityFrameworkCore.SqlServer":{"target":"Package","version":"[8.0.25, )"},"Swashbuckle.AspNetCore":{"target":"Package","version":"[10.1.7, )"}},"imports":["net461","net462","net47","net471","net472","net48","net481"],"assetTargetFallback":true,"warn":true,"frameworkReferences":{"Microsoft.AspNetCore.App":{"privateAssets":"none"},"Microsoft.NETCore.App":{"privateAssets":"all"}},"runtimeIdentifierGraphPath":"C:\\Users\\Carte\\.dotnet\\sdk\\8.0.421/PortableRuntimeIdentifierGraph.json"}}
|
"restore":{"projectUniqueName":"C:\\Users\\Carte\\RiderProjects\\Knots\\Knots\\Knots.csproj","projectName":"Knots","projectPath":"C:\\Users\\Carte\\RiderProjects\\Knots\\Knots\\Knots.csproj","packagesPath":"","outputPath":"C:\\Users\\Carte\\RiderProjects\\Knots\\Knots\\obj\\","projectStyle":"PackageReference","fallbackFolders":["C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"],"originalTargetFrameworks":["net8.0"],"sources":{"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\":{},"https://api.nuget.org/v3/index.json":{}},"frameworks":{"net8.0":{"targetAlias":"net8.0","projectReferences":{}}},"warningProperties":{"warnAsError":["NU1605"]},"restoreAuditProperties":{"enableAudit":"true","auditLevel":"low","auditMode":"direct"}}"frameworks":{"net8.0":{"targetAlias":"net8.0","dependencies":{"AutoMapper":{"target":"Package","version":"[16.1.1, )"},"BCrypt.Net-Next":{"target":"Package","version":"[4.2.0, )"},"FastEndpoints":{"target":"Package","version":"[8.0.1, )"},"FastEndpoints.Swagger":{"target":"Package","version":"[8.0.1, )"},"Microsoft.AspNetCore.Authentication":{"target":"Package","version":"[2.3.11, )"},"Microsoft.AspNetCore.Authentication.JwtBearer":{"target":"Package","version":"[8.0.28, )"},"Microsoft.AspNetCore.OpenApi":{"target":"Package","version":"[8.0.25, )"},"Microsoft.EntityFrameworkCore":{"target":"Package","version":"[8.0.25, )"},"Microsoft.EntityFrameworkCore.Design":{"include":"Runtime, Build, Native, ContentFiles, Analyzers, BuildTransitive","suppressParent":"All","target":"Package","version":"[8.0.25, )"},"Microsoft.EntityFrameworkCore.SqlServer":{"target":"Package","version":"[8.0.25, )"},"Swashbuckle.AspNetCore":{"target":"Package","version":"[10.1.7, )"}},"imports":["net461","net462","net47","net471","net472","net48","net481"],"assetTargetFallback":true,"warn":true,"frameworkReferences":{"Microsoft.AspNetCore.App":{"privateAssets":"none"},"Microsoft.NETCore.App":{"privateAssets":"all"}},"runtimeIdentifierGraphPath":"C:\\Users\\Carte\\.dotnet\\sdk\\8.0.421/PortableRuntimeIdentifierGraph.json"}}
|
||||||
@@ -1 +1 @@
|
|||||||
17810836777886837
|
17810953948669773
|
||||||
@@ -1 +1 @@
|
|||||||
17810836780793791
|
17810953954413031
|
||||||
Reference in New Issue
Block a user