mirror of
https://github.com/Athou/commafeed.git
synced 2026-10-27 07:28:54 +00:00
fix sonar warnings
This commit is contained in:
@@ -147,18 +147,17 @@ public class AdminREST {
|
||||
Map<Long, UserModel> users = new HashMap<>();
|
||||
for (UserRole role : userRoleDAO.findAll()) {
|
||||
User u = role.getUser();
|
||||
Long key = u.getId();
|
||||
UserModel userModel = users.get(key);
|
||||
if (userModel == null) {
|
||||
userModel = new UserModel();
|
||||
userModel.setId(u.getId());
|
||||
userModel.setName(u.getName());
|
||||
userModel.setEmail(u.getEmail());
|
||||
userModel.setEnabled(!u.isDisabled());
|
||||
userModel.setCreated(u.getCreated());
|
||||
userModel.setLastLogin(u.getLastLogin());
|
||||
users.put(key, userModel);
|
||||
}
|
||||
UserModel userModel = users.computeIfAbsent(u.getId(), k -> {
|
||||
UserModel um = new UserModel();
|
||||
um.setId(u.getId());
|
||||
um.setName(u.getName());
|
||||
um.setEmail(u.getEmail());
|
||||
um.setEnabled(!u.isDisabled());
|
||||
um.setCreated(u.getCreated());
|
||||
um.setLastLogin(u.getLastLogin());
|
||||
return um;
|
||||
});
|
||||
|
||||
if (role.getRole() == Role.ADMIN) {
|
||||
userModel.setAdmin(true);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class WebSocketEndpoint {
|
||||
private final WebSocketSessions sessions;
|
||||
|
||||
@OnOpen
|
||||
public void onOpen(Session session) {
|
||||
public void onOpen(Session session) throws IOException {
|
||||
User user = authenticationContext.getCurrentUser();
|
||||
if (user == null) {
|
||||
reject(session);
|
||||
@@ -53,12 +53,8 @@ public class WebSocketEndpoint {
|
||||
sessions.remove(session);
|
||||
}
|
||||
|
||||
private void reject(Session session) {
|
||||
try {
|
||||
session.close(new CloseReason(CloseCodes.VIOLATED_POLICY, "unauthorized"));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
private void reject(Session session) throws IOException {
|
||||
session.close(new CloseReason(CloseCodes.VIOLATED_POLICY, "unauthorized"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user