aboutsummaryrefslogtreecommitdiff
path: root/backend/api/api/Controllers/AuthController.cs
diff options
context:
space:
mode:
authorOgnjen Cirkovic <ciraboxkg@gmail.com>2022-03-07 00:44:07 +0100
committerOgnjen Cirkovic <ciraboxkg@gmail.com>2022-03-07 00:44:07 +0100
commit716754330e70a61ed0cb119d24a54e7bc7b4736b (patch)
tree41b07769fbaac8f473294937a19dab575447cad6 /backend/api/api/Controllers/AuthController.cs
parenta86d5871e6e1270f9863efe3642a7a1f645c980c (diff)
Napravljene klase za token i zahteve za logovanje i registrovanje.Napravljen kontroler i servis za prijavljivanje i registrovanje.
Diffstat (limited to 'backend/api/api/Controllers/AuthController.cs')
-rw-r--r--backend/api/api/Controllers/AuthController.cs34
1 files changed, 34 insertions, 0 deletions
diff --git a/backend/api/api/Controllers/AuthController.cs b/backend/api/api/Controllers/AuthController.cs
new file mode 100644
index 00000000..1f47067f
--- /dev/null
+++ b/backend/api/api/Controllers/AuthController.cs
@@ -0,0 +1,34 @@
+using api.Models.Users;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using api.Services;
+
+namespace api.Controllers
+{
+ [Route("api/[controller]")]
+ [ApiController]
+ public class AuthController : ControllerBase
+ {
+ private AuthService _auth;
+ public AuthController(IConfiguration configuration)
+ {
+ _auth=new AuthService(configuration);
+ }
+
+ [HttpPost("register")]
+ public async Task<ActionResult<string>> Register(RegisterRequest user)
+ {
+
+ return Ok(_auth.Register(user));
+ }
+
+ [HttpPost("login")]
+ public async Task<ActionResult<string>> Login(AuthRequest user)
+ {
+
+ return Ok(_auth.Login(user));
+ }
+
+
+ }
+}