Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alx-mag
Copy link

@alx-mag alx-mag commented Jun 26, 2019

A solution for #2219

@alx-mag alx-mag requested a review from knstvk June 26, 2019 12:01
@knstvk knstvk requested a review from dtsaryov June 26, 2019 12:35
@alx-mag alx-mag changed the title Add user activity check before substitution #2219 Add user activity check before substitution Jun 27, 2019
* @param user user to check
* @return true if user is active
*/
boolean isUserActive(User user);
Copy link
Contributor

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());
Copy link
Contributor

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)) {
Copy link
Contributor

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);
Copy link
Contributor

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
Copy link
Contributor

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);
}


Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same

@dtsaryov dtsaryov added this to the Release 7.2 milestone Aug 28, 2019
@dtsaryov dtsaryov added the type: enhancement New feature or request label Aug 28, 2019
@knstvk knstvk requested a review from web-devel April 23, 2020 06:53
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants