refactor: add error handling in AuthenticationResponse

This commit is contained in:
cuqmbr 2022-07-30 21:34:52 +03:00
parent 13dfc0e886
commit c3a943f02e
3 changed files with 6 additions and 3 deletions

View File

@ -24,7 +24,7 @@ public class AuthenticationController : ControllerBase
if (!success)
{
return BadRequest(content);
return BadRequest(new AuthenticationResponse {IsError = true, ErrorMessage = content} );
}
return await Login(request);
@ -38,7 +38,7 @@ public class AuthenticationController : ControllerBase
if (!success)
{
return BadRequest("Username or password is incorrect.");
return BadRequest(new AuthenticationResponse {IsError = true, ErrorMessage = "Username or password is incorrect."});
}
return Ok(new AuthenticationResponse { Token = content } );

View File

@ -2,5 +2,8 @@ namespace DatabaseModels.Responses;
public class AuthenticationResponse
{
public bool IsError { get; set; }
public string ErrorMessage { get; set; } = null!;
public string Token { get; set; } = null!;
}

View File

@ -8,7 +8,7 @@
</PropertyGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="cp ./bin/Release/net6.0/SharedModels.dll /home/danil/Unity/Projects/untiteled-mobile-game/Assets/Imported\ Assets/Plugins/SharedModels.dll" />
<Exec Command="cp ./bin/Release/net6.0/SharedModels.dll /home/danil/Unity/Projects/untiteled-mobile-game/Assets/Imported\ Assets/SharedModels.dll" />
</Target>
</Project>