Change sign-up url, Add whoami endpoint

This commit is contained in:
Marcel Schwarz 2020-05-09 19:20:35 +02:00
parent 6abdab2cf6
commit f186a89bb8
2 changed files with 2 additions and 3 deletions

View File

@ -5,5 +5,5 @@ public class SecurityConstants {
public static final long EXPIRATION_TIME = 864_000_000; // 10 days public static final long EXPIRATION_TIME = 864_000_000; // 10 days
public static final String TOKEN_PREFIX = "Bearer "; public static final String TOKEN_PREFIX = "Bearer ";
public static final String HEADER_STRING = "Authorization"; public static final String HEADER_STRING = "Authorization";
public static final String SIGN_UP_URL = "/user/sign-up"; public static final String SIGN_UP_URL = "/sign-up";
} }

View File

@ -7,7 +7,6 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@RestController @RestController
@RequestMapping("/user")
public class UserController { public class UserController {
private final TimetrackUserRepository userRepository; private final TimetrackUserRepository userRepository;
@ -18,7 +17,7 @@ public class UserController {
this.bCryptPasswordEncoder = bCryptPasswordEncoder; this.bCryptPasswordEncoder = bCryptPasswordEncoder;
} }
@GetMapping @GetMapping("/whoami")
public String getUsername(Authentication authentication) { public String getUsername(Authentication authentication) {
TimetrackUser timetrackUser = userRepository.findFirstByUsername(authentication.getName()); TimetrackUser timetrackUser = userRepository.findFirstByUsername(authentication.getName());
return "Welcome back " + timetrackUser.getFirstname() + " " + timetrackUser.getLastname(); return "Welcome back " + timetrackUser.getFirstname() + " " + timetrackUser.getLastname();