Skip to content

Commit 64d1884

Browse files
add authdto
1 parent 5481031 commit 64d1884

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

NorthwindCRUD/Controllers/AuthController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public ActionResult<string> Register(RegisterDto userModel)
9292

9393
[AllowAnonymous]
9494
[HttpPost("LoginObject")]
95-
public ActionResult<string> LoginObject(LoginDto userModel)
95+
public ActionResult<AuthDto> LoginObject(LoginDto userModel)
9696
{
9797
try
9898
{
@@ -102,7 +102,7 @@ public ActionResult<string> LoginObject(LoginDto userModel)
102102
{
103103
var token = this.authService.GenerateJwtToken(userModel.Email);
104104

105-
return Ok(new { token });
105+
return Ok(new AuthDto() { Token = token });
106106
}
107107

108108
return BadRequest("Email or password are not correct!");
@@ -119,7 +119,7 @@ public ActionResult<string> LoginObject(LoginDto userModel)
119119

120120
[AllowAnonymous]
121121
[HttpPost("RegisterObject")]
122-
public ActionResult<string> RegisterObject(RegisterDto userModel)
122+
public ActionResult<AuthDto> RegisterObject(RegisterDto userModel)
123123
{
124124
try
125125
{
@@ -141,7 +141,7 @@ public ActionResult<string> RegisterObject(RegisterDto userModel)
141141
if (user != null)
142142
{
143143
var token = this.authService.GenerateJwtToken(user.Email);
144-
return Ok(new { token });
144+
return Ok(new AuthDto() { Token = token });
145145
}
146146

147147
return BadRequest("Email or password are not correct!");
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace NorthwindCRUD.Models.Dtos
2+
{
3+
public class AuthDto
4+
{
5+
public string Token { get; set; }
6+
}
7+
}

0 commit comments

Comments
 (0)