diff options
Diffstat (limited to 'src/main/java/com/juick/service')
3 files changed, 3 insertions, 9 deletions
diff --git a/src/main/java/com/juick/service/UserService.java b/src/main/java/com/juick/service/UserService.java index 53acdfab..0cbe104f 100644 --- a/src/main/java/com/juick/service/UserService.java +++ b/src/main/java/com/juick/service/UserService.java @@ -123,8 +123,6 @@ public interface UserService { void updateLastSeen(User user); - boolean isAdminUser(User user); - Optional<ExternalToken> getTwitterToken(int uid); @CacheEvict(value = "twitter_user", key="{ #uid }") diff --git a/src/main/java/com/juick/service/UserServiceImpl.java b/src/main/java/com/juick/service/UserServiceImpl.java index a7ea5c5f..442bd03c 100644 --- a/src/main/java/com/juick/service/UserServiceImpl.java +++ b/src/main/java/com/juick/service/UserServiceImpl.java @@ -66,6 +66,7 @@ public class UserServiceImpl extends BaseJdbcService implements UserService { } user.setVerified(rs.getLong(6) > 0); user.setPremium(rs.getInt(7) > 0); + user.setAdmin(adminUsers.contains(user.getName())); return user; } } @@ -595,11 +596,6 @@ public class UserServiceImpl extends BaseJdbcService implements UserService { getJdbcTemplate().update("UPDATE users SET last_seen=? WHERE id=?", toDateTime(Instant.now().atOffset(ZoneOffset.UTC)), user.getUid()); } - @Override - public boolean isAdminUser(User user) { - return adminUsers.contains(user.getName()); - } - @Transactional(readOnly = true) @Override public Optional<ExternalToken> getTwitterToken(final int uid) { diff --git a/src/main/java/com/juick/service/security/JuickUserDetailsService.java b/src/main/java/com/juick/service/security/JuickUserDetailsService.java index e64a0c8e..9371b863 100644 --- a/src/main/java/com/juick/service/security/JuickUserDetailsService.java +++ b/src/main/java/com/juick/service/security/JuickUserDetailsService.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2020, Juick + * Copyright (C) 2008-2023, Juick * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -49,7 +49,7 @@ public class JuickUserDetailsService implements UserDetailsService { if (!user.isAnonymous()) { user.setAuthHash(userService.getHashByUID(user.getUid())); - List<GrantedAuthority> authorities = userService.isAdminUser(user) ? + List<GrantedAuthority> authorities = user.isAdmin() ? JuickUser.ADMIN_AUTHORITY : JuickUser.USER_AUTHORITY; return new JuickUser(user, authorities); } |