Compare commits

..

No commits in common. "e62390abc999867c1cac6a6f8031b8e1aa99b64f" and "9f142abd51a8e8e0e847c778ac222c8bafb6ac46" have entirely different histories.

6 changed files with 1 additions and 107 deletions

View File

@ -26,22 +26,6 @@ namespace Api.Controllers
_tokenParameters = tokenParameters;
}
[HttpPost("register")]
[AllowAnonymous]
public async Task<ActionResult> Register(RegisterViewModel command)
{
var user = new User(command.Username);
var result = await _usersManager.CreateAsync(user, command.Password);
if (!result.Succeeded)
{
return BadRequest();
}
return NoContent();
}
/// <summary>
/// Récupère un jeton d'accès pour un utilisateur particulier.
/// </summary>

View File

@ -1,13 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Api.Models
{
public sealed class RegisterViewModel
{
[Required]
public string Username { get; set; }
[Required]
public string Password { get; set; }
}
}

View File

@ -9,7 +9,6 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.AspNetCore.Routing;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@ -56,11 +55,7 @@ namespace Api
services.AddSingleton(tokenParams);
services.AddIdentityCore<User>(o =>
{
o.Password.RequiredLength = o.Password.RequiredUniqueChars = 0;
o.Password.RequireDigit = o.Password.RequireLowercase = o.Password.RequireNonAlphanumeric = o.Password.RequireUppercase = false;
})
services.AddIdentityCore<User>()
.AddRoles<Role>()
.AddEntityFrameworkStores<HNDbContext>()
.AddSignInManager();
@ -111,8 +106,6 @@ namespace Api
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
MigrateDatabase(app);
app.UseOpenApi();
if (env.IsDevelopment())
@ -142,17 +135,5 @@ namespace Api
});
});
}
/// <summary>
/// Lance les migrations. En production, il est plutôt conseillé de générer
/// les scripts avec `dotnet ef migrations script` et de les passer à la main.
/// </summary>
/// <param name="app"></param>
private void MigrateDatabase(IApplicationBuilder app)
{
using var scope = app.ApplicationServices.CreateScope();
using var ctx = scope.ServiceProvider.GetRequiredService<HNDbContext>();
ctx.Database.Migrate();
}
}
}

View File

@ -6,39 +6,6 @@
"version": "1.0.0"
},
"paths": {
"/api/accounts/register": {
"post": {
"tags": [
"Accounts"
],
"operationId": "Accounts_Register",
"requestBody": {
"x-name": "command",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RegisterViewModel"
}
}
},
"required": true,
"x-position": 1
},
"responses": {
"200": {
"description": "",
"content": {
"application/octet-stream": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
}
}
}
},
"/api/accounts/login": {
"post": {
"tags": [
@ -342,24 +309,6 @@
},
"components": {
"schemas": {
"RegisterViewModel": {
"type": "object",
"additionalProperties": false,
"required": [
"username",
"password"
],
"properties": {
"username": {
"type": "string",
"minLength": 1
},
"password": {
"type": "string",
"minLength": 1
}
}
},
"LoginViewModel": {
"type": "object",
"additionalProperties": false,

View File

@ -6,11 +6,8 @@ COPY Application/*.csproj ./Application/
COPY Domain/*.csproj ./Domain/
COPY Infrastructure/*.csproj ./Infrastructure/
COPY Apps/Api/*.csproj ./Apps/Api/
WORKDIR /source/Apps/Api
RUN dotnet restore
WORKDIR /source
COPY Application/. ./Application/
COPY Domain/. ./Domain/
COPY Infrastructure/. ./Infrastructure/
@ -22,6 +19,5 @@ RUN dotnet publish -c release -o /app --no-restore
FROM mcr.microsoft.com/dotnet/aspnet:5.0
WORKDIR /app
COPY --from=build /app ./
ENV "ConnectionStrings:Default"="Data Source=hn.db"
EXPOSE 80
ENTRYPOINT ["dotnet", "Api.dll"]

View File

@ -1,3 +0,0 @@
build:
docker:
web: Dockerfile