revert: revert authentication response extension
This reverts commit f158bad756
.
This commit is contained in:
parent
f158bad756
commit
f14ece42ff
@ -41,7 +41,6 @@ public class AuthenticationController : ControllerBase
|
|||||||
return BadRequest("Username or password is incorrect.");
|
return BadRequest("Username or password is incorrect.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var userId = await _authenticationService.GetIdByUsername(request.Username);
|
return Ok(new AuthenticationResponse { Token = content } );
|
||||||
return Ok(new AuthenticationResponse { UserId = userId, Token = content } );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,6 +14,7 @@ var builder = WebApplication.CreateBuilder(args);
|
|||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
|
|
||||||
builder.Services.AddControllers().AddNewtonsoftJson(o => {
|
builder.Services.AddControllers().AddNewtonsoftJson(o => {
|
||||||
|
o.SerializerSettings.ContractResolver = new DefaultContractResolver();
|
||||||
o.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
|
o.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
|
||||||
});
|
});
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
@ -59,12 +59,6 @@ public class AuthenticationService
|
|||||||
return (true, GenerateJwtToken(AssembleClaimsIdentity(user)));
|
return (true, GenerateJwtToken(AssembleClaimsIdentity(user)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GetIdByUsername(string username)
|
|
||||||
{
|
|
||||||
var dbUser = await _dbContext.Users.FirstAsync(u => u.Username == username);
|
|
||||||
return dbUser.Id;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ClaimsIdentity AssembleClaimsIdentity(User user)
|
private ClaimsIdentity AssembleClaimsIdentity(User user)
|
||||||
{
|
{
|
||||||
var subject = new ClaimsIdentity(new[] {
|
var subject = new ClaimsIdentity(new[] {
|
||||||
|
@ -2,6 +2,5 @@ namespace DatabaseModels.Responses;
|
|||||||
|
|
||||||
public class AuthenticationResponse
|
public class AuthenticationResponse
|
||||||
{
|
{
|
||||||
public int UserId { get; set; }
|
|
||||||
public string Token { get; set; } = null!;
|
public string Token { get; set; } = null!;
|
||||||
}
|
}
|
@ -7,8 +7,4 @@
|
|||||||
<RootNamespace>DatabaseModels</RootNamespace>
|
<RootNamespace>DatabaseModels</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
|
||||||
<Exec Command="cp ./bin/Release/net6.0/SharedModels.dll /home/danil/Unity/Projects/untiteled-mobile-game/Assets/SharedModels.dll" />
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
Reference in New Issue
Block a user