Skip to content

Commit

Permalink
fix(auth): handling logged-in user with no roles (#1589)
Browse files Browse the repository at this point in the history
Fix #1586
  • Loading branch information
AlexisSouquiere authored Nov 19, 2023
1 parent 8214a11 commit 4d031f9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
28 changes: 16 additions & 12 deletions client/src/containers/Login/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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!');
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/akhq/controllers/AbstractController.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ protected List<Group> 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()));
}

Expand Down

0 comments on commit 4d031f9

Please sign in to comment.