Skip to content
This repository has been archived by the owner on Feb 14, 2022. It is now read-only.

Commit

Permalink
Auto validate invited users
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis-Cruz committed Dec 13, 2021
1 parent 1891839 commit 187c801
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/main/java/pt/ist/fenix/webapp/CreateUserAccounts.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 187c801

Please sign in to comment.