controllers docs checkpoint
This commit is contained in:
@ -11,6 +11,10 @@ import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.authentication.AnonymousAuthenticationToken;
|
||||
|
||||
/**
|
||||
* Abstract class for controllers that requires token to extra authorize action
|
||||
* beyond spring security
|
||||
*/
|
||||
public abstract class TokenBasedController {
|
||||
@Autowired
|
||||
protected UserService userService;
|
||||
@ -18,6 +22,10 @@ public abstract class TokenBasedController {
|
||||
public TokenBasedController() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return get currect user based no current spring context
|
||||
* @throws UserNotFoundException if user was not fount
|
||||
*/
|
||||
protected Optional<User> getCurrentUser() throws UserNotFoundException {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
|
||||
|
Reference in New Issue
Block a user