diff --git a/client/src/containers/Login/Login.jsx b/client/src/containers/Login/Login.jsx index 9e9f0deea..724996876 100644 --- a/client/src/containers/Login/Login.jsx +++ b/client/src/containers/Login/Login.jsx @@ -68,18 +68,22 @@ class Login extends Form { const currentUserData = res.data; if (currentUserData.logged) { - sessionStorage.setItem('login', true); - sessionStorage.setItem('user', currentUserData.username); - sessionStorage.setItem('roles', organizeRoles(currentUserData.roles)); - - const returnTo = sessionStorage.getItem('returnTo'); - sessionStorage.removeItem('returnTo'); - - this.props.history.push({ - pathname: returnTo || '/ui' - }); - - window.location.reload(true); + if (currentUserData.roles) { + sessionStorage.setItem('login', true); + sessionStorage.setItem('user', currentUserData.username); + sessionStorage.setItem('roles', organizeRoles(currentUserData.roles)); + + const returnTo = sessionStorage.getItem('returnTo'); + sessionStorage.removeItem('returnTo'); + + this.props.history.push({ + pathname: returnTo || '/ui' + }); + + window.location.reload(true); + } else { + toast.error('User logged in but no roles assigned'); + } } else { toast.error('Wrong Username or Password!'); } diff --git a/src/main/java/org/akhq/controllers/AbstractController.java b/src/main/java/org/akhq/controllers/AbstractController.java index 5aef8ff6c..64e23f9ac 100644 --- a/src/main/java/org/akhq/controllers/AbstractController.java +++ b/src/main/java/org/akhq/controllers/AbstractController.java @@ -60,7 +60,8 @@ protected List getUserGroups() { .collect(Collectors.toList()); // Add the default group if there is one - if (groupBindings.isEmpty() && StringUtils.isNotEmpty(securityProperties.getDefaultGroup())) { + if (groupBindings.isEmpty() && StringUtils.isNotEmpty(securityProperties.getDefaultGroup()) + && securityProperties.getGroups().get(securityProperties.getDefaultGroup()) != null) { groupBindings.addAll(securityProperties.getGroups().get(securityProperties.getDefaultGroup())); }