Change mapping to Rest

This commit is contained in:
redtea committed 2022-08-30 23:26:56 +03:00
1 parent 10a8502491
commit e46e304975
43 files changed
+597 -206

No files matched your search

@@ -5,7 +5,7 @@ import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import site.easystartup.web.domain.User;
import site.easystartup.web.domain.model.User;
import site.easystartup.web.repo.UserRepo;
import java.security.Principal;
@@ -22,12 +22,4 @@ public class UserService {
public User getUserById(Long userId) {
return userRepo.findById(userId).orElseThrow(() -> new UsernameNotFoundException("User not found"));
}
public User getCurrentUser() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if(auth.isAuthenticated()) throw new UserNotAuthenticatedException();
org.springframework.security.core.userdetails.User user = (org.springframework.security.core.userdetails.User)
auth.getPrincipal();
return userRepo.findByUsername(user.getUsername());
}
}