Skip to content

Commit

Permalink
required changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Johna91 committed Feb 1, 2024
1 parent c11912e commit 91af22b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.sportsmatch.controllers;

import com.sportsmatch.models.User;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -11,6 +12,7 @@
public class APIController {

@GetMapping("/hello")
@Tag(name = "ex.secured endpoint")
public String hello(Authentication authentication) {
User user = (User) authentication.getPrincipal();
return "Welcome " + user.getName() + " to Secured Endpoint ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ public ResponseEntity<?> register(
}
}

@PostMapping("/authenticate")
public ResponseEntity<?> authenticate(
@PostMapping("/login")
@Tag(name = "Login")
@Operation(
summary = "Login user",
description = "Login a user by providing their email and username.")
public ResponseEntity<?> login(
@RequestBody @Valid AuthRequestDTO authRequestDTO, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResponseEntity.badRequest().body(validationService.getAllErrors(bindingResult));
Expand Down

0 comments on commit 91af22b

Please sign in to comment.