mirror of
https://github.com/Athou/commafeed.git
synced 2026-09-27 22:44:42 +00:00
WIP
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package com.commafeed.security;
|
||||
|
||||
import com.commafeed.backend.dao.UserDAO;
|
||||
import com.commafeed.backend.model.User;
|
||||
|
||||
import io.quarkus.security.identity.SecurityIdentity;
|
||||
import jakarta.inject.Singleton;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Singleton
|
||||
public class AuthenticationContext {
|
||||
|
||||
private final SecurityIdentity securityIdentity;
|
||||
private final UserDAO userDAO;
|
||||
|
||||
public User getCurrentUser() {
|
||||
if (securityIdentity.isAnonymous()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String userId = securityIdentity.getPrincipal().getName();
|
||||
if (userId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return userDAO.findById(Long.valueOf(userId));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user