source: backend/src/main/java/com/finki/icare/controller/AuthController.java

main
Last change on this file was 700e2f9, checked in by 186079 <matej.milevski@…>, 5 days ago

Init

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[700e2f9]1package com.finki.icare.controller;
2
3import com.finki.icare.dto.LoginRequest;
4import com.finki.icare.dto.LoginResponse;
5import com.finki.icare.dto.RegisterPatientRequest;
6import com.finki.icare.dto.RegisterTherapistRequest;
7import com.finki.icare.service.AuthService;
8import org.springframework.http.HttpStatus;
9import org.springframework.http.ResponseEntity;
10import org.springframework.web.bind.annotation.*;
11
12@RestController
13@RequestMapping("/api/auth")
14@CrossOrigin(origins = "http://localhost:3000")
15public class AuthController {
16
17 private final AuthService authService;
18
19 public AuthController(AuthService authService) {
20 this.authService = authService;
21 }
22
23 @PostMapping("/login")
24 public ResponseEntity<LoginResponse> login(@RequestBody LoginRequest request) {
25 LoginResponse response = authService.login(request);
26 return ResponseEntity.ok(response);
27 }
28
29 @PostMapping("/register/patient")
30 public ResponseEntity<LoginResponse> registerPatient(@RequestBody RegisterPatientRequest request) {
31 LoginResponse response = authService.registerPatient(request);
32 return ResponseEntity.status(HttpStatus.CREATED).body(response);
33 }
34
35 @PostMapping("/register/therapist")
36 public ResponseEntity<LoginResponse> registerTherapist(@RequestBody RegisterTherapistRequest request) {
37 LoginResponse response = authService.registerTherapist(request);
38 return ResponseEntity.status(HttpStatus.CREATED).body(response);
39 }
40}
Note: See TracBrowser for help on using the repository browser.