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
No related merge requests found
......@@ -28,6 +28,8 @@ import java.util.UUID;
* The functionality the user service should provide.
*/
public interface UserService {
UserProfile getCurrentUserProfile();
UserAuthentication getCurrentUser();
boolean isAdmin(String username);
......@@ -58,6 +60,8 @@ public interface UserService {
int loggedInUsers();
UserProfile getByAuthProviderAndLoginId(UserProfile.AuthProvider authProvider, String loginId);
UserProfile getByUsername(String username);
UserProfile create(String username, String password);
......
......@@ -179,6 +179,12 @@ public class UserServiceImpl implements UserService {
userRepository.deleteInactiveUsers(lastActivityBefore);
}
@Override
public UserProfile getCurrentUserProfile() {
final UserAuthentication authentication = getCurrentUser();
return getByAuthProviderAndLoginId(authentication.getAuthProvider(), authentication.getUsername());
}
@Override
public UserAuthentication getCurrentUser() {
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
......@@ -355,6 +361,11 @@ public class UserServiceImpl implements UserService {
return userToRoomId.size();
}
@Override
public UserProfile getByAuthProviderAndLoginId(final UserProfile.AuthProvider authProvider, final String loginId) {
return userRepository.findByAuthProviderAndLoginId(authProvider, loginId);
}
@Override
public UserProfile getByUsername(String username) {
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