From 187c801968c9f8ec3e6cebe27b395e9e763e7413 Mon Sep 17 00:00:00 2001 From: Luis Cruz Date: Mon, 13 Dec 2021 12:58:03 +0000 Subject: [PATCH] Auto validate invited users --- .../pt/ist/fenix/webapp/CreateUserAccounts.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/pt/ist/fenix/webapp/CreateUserAccounts.java b/src/main/java/pt/ist/fenix/webapp/CreateUserAccounts.java index 99d74733..01780034 100644 --- a/src/main/java/pt/ist/fenix/webapp/CreateUserAccounts.java +++ b/src/main/java/pt/ist/fenix/webapp/CreateUserAccounts.java @@ -17,8 +17,6 @@ import org.fenixedu.bennu.core.domain.UserProfile; import org.fenixedu.bennu.scheduler.CronTask; import org.fenixedu.bennu.scheduler.annotation.Task; -import org.fenixedu.bennu.scheduler.custom.CustomTask; -import org.fenixedu.bennu.scheduler.custom.ReadCustomTask; import org.fenixedu.connect.domain.Account; import org.fenixedu.connect.domain.ConnectSystem; import org.fenixedu.connect.domain.Identity; @@ -41,6 +39,7 @@ import pt.ist.fenixedu.contracts.domain.accessControl.ActiveEmployees; import pt.ist.fenixedu.contracts.domain.accessControl.ActiveGrantOwner; import pt.ist.fenixedu.contracts.domain.accessControl.ActiveResearchers; +import pt.ist.fenixedu.contracts.domain.organizationalStructure.Invitation; import pt.ist.fenixframework.FenixFramework; import pt.ist.standards.geographic.Planet; @@ -276,7 +275,18 @@ private boolean isStudentOrTeacherOrEmployee(final User user) { return true; } } - return new ActiveEmployees().isMember(user) || new ActiveResearchers().isMember(user) || new ActiveGrantOwner().isMember(user); + return new ActiveEmployees().isMember(user) + || new ActiveResearchers().isMember(user) + || new ActiveGrantOwner().isMember(user) + || hasActiveInvite(user); + } + + private boolean hasActiveInvite(final User user) { + return user.getPerson() != null && user.getPerson().getParentsSet().stream() + .filter(Invitation.class::isInstance) + .map(Invitation.class::cast) + .anyMatch(invitation -> invitation.isActive()); + } private void createAccount(final User user) {