mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-03 09:39:38 +00:00
fix user management "locked until" column not updating after unlock
The unlocked user's entry is updated locally with a entry.copyWithLockedUntil, inserted in the list of all entries and displayed.
This commit is contained in:
1 parent
2ea8fa37eb
commit
96eb02df0c
2 files changed
+38
-17
No files matched your search
@@ -59,7 +59,22 @@ public class UserDTO extends
|
||||
Util.addAll(roles, this.getRolesInternal());
|
||||
this.lockedUntil = lockedUntil;
|
||||
}
|
||||
|
||||
|
||||
public UserDTO copyWithTimePoint(TimePoint lockedUntil) {
|
||||
final List<AccountDTO> accountsCopy = new ArrayList<AccountDTO>();
|
||||
Util.addAll(this.accounts, accountsCopy);
|
||||
final HashSet<RoleWithSecurityDTO> rolesCopy = new HashSet<>();
|
||||
Util.addAll(this.roles, rolesCopy);
|
||||
final List<WildcardPermissionWithSecurityDTO> permissionsCopy = new ArrayList<WildcardPermissionWithSecurityDTO>();
|
||||
for (WildcardPermission wp : this.getPermissions()) {
|
||||
permissionsCopy.add((WildcardPermissionWithSecurityDTO) wp);
|
||||
}
|
||||
final List<StrippedUserGroupDTO> groupsCopy = new ArrayList<StrippedUserGroupDTO>();
|
||||
Util.addAll(this.groups, groupsCopy);
|
||||
return new UserDTO(this.getName(), this.email, this.fullName, this.company, this.locale, this.emailValidated,
|
||||
accountsCopy, rolesCopy, this.defaultTenantForCurrentServer, permissionsCopy, groupsCopy, lockedUntil);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<RoleWithSecurityDTO> getRolesInternal() {
|
||||
return roles;
|
||||
|
||||
+22
-16
@@ -250,27 +250,33 @@ extends TableWrapper<UserDTO, S, StringMessages, TR> {
|
||||
}
|
||||
|
||||
private Consumer<UserDTO> onManageLockPressed(StringMessages stringMessages, ErrorReporter errorReporter) {
|
||||
return user -> {
|
||||
final boolean isLocked = user.getLockedUntil().after(TimePoint.now());
|
||||
return selectedUser -> {
|
||||
final boolean isLocked = selectedUser.getLockedUntil().after(TimePoint.now());
|
||||
if (isLocked) {
|
||||
final String userName = user.getName();
|
||||
final String userName = selectedUser.getName();
|
||||
final boolean didConfirm = Window.confirm(stringMessages.doYouReallyWantToUnlockUser(userName));
|
||||
if (didConfirm) {
|
||||
getUserManagementWriteService().unlockUser(
|
||||
userName,
|
||||
new AsyncCallback<SuccessInfo>() {
|
||||
@Override
|
||||
public void onSuccess(SuccessInfo result) {
|
||||
Window.alert(stringMessages.unlockSucceededFor(userName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert(stringMessages.unlockFailedFor(userName));
|
||||
errorReporter.reportError(caught.getMessage());
|
||||
getUserManagementWriteService().unlockUser(userName, new AsyncCallback<SuccessInfo>() {
|
||||
@Override
|
||||
public void onSuccess(SuccessInfo result) {
|
||||
Window.alert(stringMessages.unlockSucceededFor(userName));
|
||||
final List<UserDTO> usersWithUpdate = new ArrayList<UserDTO>();
|
||||
for (UserDTO user : getAllUsers()) {
|
||||
if (user.getFullName() == selectedUser.getFullName()) {
|
||||
usersWithUpdate.add(user.copyWithTimePoint(null));
|
||||
} else {
|
||||
usersWithUpdate.add(user);
|
||||
}
|
||||
}
|
||||
filterField.updateAll(usersWithUpdate);
|
||||
}
|
||||
);
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert(stringMessages.unlockFailedFor(userName));
|
||||
errorReporter.reportError(caught.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
Window.alert(stringMessages.userIsAlreadyUnlocked());
|
||||
|
||||
Reference in new issue
Block a user