Skip to content

Commit

Permalink
Update AuthController.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdugafur111 authored Feb 19, 2023
1 parent 6bdebcf commit aba040f
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions expo/src/main/java/com/expo/spring/controllers/AuthController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
import com.expo.spring.models.Person;
import com.expo.spring.services.RegistrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@Controller
@RestController
@RequestMapping("/auth")
public class AuthController {
private final RegistrationService registrationService;
Expand All @@ -18,24 +16,27 @@ public class AuthController {
public AuthController(RegistrationService registrationService) {
this.registrationService = registrationService;
}

@GetMapping("/login")
public String loginPage() {
return "auth/login";
public ResponseEntity<String> loginPage() {
return new ResponseEntity<>("Login page", HttpStatus.OK);
}


@GetMapping("/registration")
public String registrationPage(@ModelAttribute("person") Person person1) {
return "auth/registration";
public ResponseEntity<Person> registrationPage() {
System.out.println("asd");
return new ResponseEntity<>(new Person(), HttpStatus.OK);
}


@PostMapping("/registration")
public String performRegistration(@ModelAttribute("person") Person person) {

/*
{"id":1992,"fullName":"Abdu","yearOfBirth":1992,"password":"korea12","role":null}
*/
@PostMapping("/registration")
public ResponseEntity<String> performRegistration(@RequestBody Person person) {
System.out.println("hello");
registrationService.register(person);

return "redirect:/auth/login";
return new ResponseEntity<>("Registration successful", HttpStatus.CREATED);
}

}

0 comments on commit aba040f

Please sign in to comment.