Skip to content
Snippets Groups Projects
Commit 219bcea7 authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Add methods to retrieve non-native users

parent a2991fe5
Branches
No related merge requests found
...@@ -28,6 +28,8 @@ import java.util.UUID; ...@@ -28,6 +28,8 @@ import java.util.UUID;
* The functionality the user service should provide. * The functionality the user service should provide.
*/ */
public interface UserService { public interface UserService {
UserProfile getCurrentUserProfile();
UserAuthentication getCurrentUser(); UserAuthentication getCurrentUser();
boolean isAdmin(String username); boolean isAdmin(String username);
...@@ -58,6 +60,8 @@ public interface UserService { ...@@ -58,6 +60,8 @@ public interface UserService {
int loggedInUsers(); int loggedInUsers();
UserProfile getByAuthProviderAndLoginId(UserProfile.AuthProvider authProvider, String loginId);
UserProfile getByUsername(String username); UserProfile getByUsername(String username);
UserProfile create(String username, String password); UserProfile create(String username, String password);
......
...@@ -179,6 +179,12 @@ public class UserServiceImpl implements UserService { ...@@ -179,6 +179,12 @@ public class UserServiceImpl implements UserService {
userRepository.deleteInactiveUsers(lastActivityBefore); userRepository.deleteInactiveUsers(lastActivityBefore);
} }
@Override
public UserProfile getCurrentUserProfile() {
final UserAuthentication authentication = getCurrentUser();
return getByAuthProviderAndLoginId(authentication.getAuthProvider(), authentication.getUsername());
}
@Override @Override
public UserAuthentication getCurrentUser() { public UserAuthentication getCurrentUser() {
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
...@@ -355,6 +361,11 @@ public class UserServiceImpl implements UserService { ...@@ -355,6 +361,11 @@ public class UserServiceImpl implements UserService {
return userToRoomId.size(); return userToRoomId.size();
} }
@Override
public UserProfile getByAuthProviderAndLoginId(final UserProfile.AuthProvider authProvider, final String loginId) {
return userRepository.findByAuthProviderAndLoginId(authProvider, loginId);
}
@Override @Override
public UserProfile getByUsername(String username) { public UserProfile getByUsername(String username) {
return userRepository.findByAuthProviderAndLoginId(UserProfile.AuthProvider.ARSNOVA, username.toLowerCase()); return userRepository.findByAuthProviderAndLoginId(UserProfile.AuthProvider.ARSNOVA, username.toLowerCase());
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment