Skip to content
Snippets Groups Projects
Commit 574e96a8 authored by Lucca Santangelo's avatar Lucca Santangelo
Browse files

id en login y configuracion swagger para docker

parent 6863fa73
No related branches found
No related tags found
No related merge requests found
# https://hub.docker.com/_/microsoft-dotnet-core
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /app
EXPOSE 5000
# copy csproj and restore as distinct layers
WORKDIR /src
......@@ -20,4 +19,5 @@ RUN dotnet publish -c release -o /app/publish
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY --from=build /app/publish .
EXPOSE 5000
ENTRYPOINT ["dotnet", "Tsi1.Api.dll"]
\ No newline at end of file
......@@ -55,6 +55,7 @@ namespace Tsi1.Api.Controllers
return Ok(new LoginResult
{
Id = user.Id,
UserName = user.Username,
Role = user.UserType.Name,
AccessToken = jwtResult.AccessToken,
......@@ -69,6 +70,7 @@ namespace Tsi1.Api.Controllers
try
{
var username = HttpContext.User.Claims.FirstOrDefault(x => x.Type == "Username").Value;
var id = int.Parse(HttpContext.User.Claims.FirstOrDefault(x => x.Type == "Id").Value);
if (string.IsNullOrWhiteSpace(request.RefreshToken))
{
......@@ -80,6 +82,7 @@ namespace Tsi1.Api.Controllers
return Ok(new LoginResult
{
Id = id,
UserName = username,
Role = User.FindFirst(ClaimTypes.Role)?.Value ?? string.Empty,
AccessToken = jwtResult.AccessToken,
......
......@@ -8,6 +8,9 @@ namespace Tsi1.Api.Models
{
public class LoginResult
{
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("username")]
public string UserName { get; set; }
......
......@@ -134,16 +134,28 @@ namespace Tsi1.Api
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Tsi1 api V1");
c.DocumentTitle = "Tsi1 api";
});
}
// app.UseHttpsRedirection();
app.UseSwagger();
app.UseSwaggerUI(c =>
else
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Tsi1 api V1");
c.DocumentTitle = "Tsi1 api";
});
app.UseSwagger(c =>
{
c.PreSerializeFilters.Add((swagger, httpReq) =>
{
swagger.Servers = new List<OpenApiServer> { new OpenApiServer { Url = $"{httpReq.Scheme}://localhost/back" } };
});
});
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("http://localhost/back/swagger/v1/swagger.json", "Tsi1 api V1");
c.DocumentTitle = "Tsi1 api";
});
}
app.UseRouting();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment