aboutsummaryrefslogtreecommitdiff
path: root/Backend/Api/Api/Controllers/AuthController.cs
diff options
context:
space:
mode:
authorbranislav.radivojevic <wafflemynxyt@gmail.com>2022-10-28 15:58:37 +0200
committerbranislav.radivojevic <wafflemynxyt@gmail.com>2022-10-28 15:58:37 +0200
commit174a2de4261dc2f4ea89e20a661a6a69475ed45a (patch)
tree39df185dde9d3d02c0bdd80b7f82c6dc00897162 /Backend/Api/Api/Controllers/AuthController.cs
parentd2f98610ddfd63f39c2a2c5b43030bfb4a0ce0a0 (diff)
login and register pw encrypt, return jwt
Diffstat (limited to 'Backend/Api/Api/Controllers/AuthController.cs')
-rw-r--r--Backend/Api/Api/Controllers/AuthController.cs13
1 files changed, 13 insertions, 0 deletions
diff --git a/Backend/Api/Api/Controllers/AuthController.cs b/Backend/Api/Api/Controllers/AuthController.cs
index 456abd9..6727125 100644
--- a/Backend/Api/Api/Controllers/AuthController.cs
+++ b/Backend/Api/Api/Controllers/AuthController.cs
@@ -33,5 +33,18 @@ namespace Api.Controllers
return Ok();
}
+ [HttpPost("login")]
+ public async Task<ActionResult<string>> Login([FromBody] Login creds)
+ {
+ var id = await _userService.UserIdFromJwt();
+ if (id != null) return Forbid();
+
+ var jwt= await _userService.Login(creds);
+ if (jwt != null)
+ {
+ return Ok(new { token = jwt });
+ }
+ return BadRequest();
+ }
}
}