-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add user activity check before substitution #2220
base: master
Are you sure you want to change the base?
Conversation
* @param user user to check | ||
* @return true if user is active | ||
*/ | ||
boolean isUserActive(User user); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move a code from AuthenticationManager
& AuthenticationService
to UserManagementService
@Override | ||
public boolean isUserActive(User user) { | ||
try (Transaction ignored = persistence.createTransaction()) { | ||
User foundUser = persistence.getEntityManager().find(User.class, user.getId()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a 'user'
@@ -42,25 +44,36 @@ public ChangeSubstUserAction(User user) { | |||
public void actionPerform(com.haulmont.cuba.gui.components.Component component) { | |||
AppUI ui = AppUI.getCurrent(); | |||
|
|||
WebScreens screens = (WebScreens) ui.getScreens(); | |||
if (!isUserActive(user)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fail fast:
if (notActive) {
showNotification()
doRevert();
return;
}
WebScreens screens = ...
}) | ||
.otherwise(this::doRevert); | ||
private static boolean isUserActive(User user) { | ||
return AppBeans.<AuthenticationService>get(AuthenticationService.NAME).isUserActive(user); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
T foo = AppBeans.get(T.class);
@@ -73,4 +73,11 @@ | |||
* @throws NoUserSessionException if session is absent or expired | |||
*/ | |||
void logout(); | |||
|
|||
/** | |||
* Check if user is active |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omit this part when the @return
has the same description
return authenticationManager.isUserActive(user); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra space
@@ -73,4 +73,11 @@ | |||
* @see AuthenticationService#logout() | |||
*/ | |||
void logout(); | |||
|
|||
/** | |||
* Checks if user is active |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same
Alexander Magomedov seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
A solution for #2219