Merge pull request #1410 from sharmapankaj2512/MIFOSX-1935
MIFOSX-1935: role with no active user attached will get deleted
This commit is contained in:
+1
@@ -296,6 +296,7 @@ public class AppUser extends AbstractPersistable<Long> implements PlatformUser {
|
||||
this.accountNonExpired = false;
|
||||
this.firstTimeLoginRemaining = true;
|
||||
this.username = getId() + "_DELETED_" + this.username;
|
||||
this.roles.clear();
|
||||
}
|
||||
|
||||
public boolean isDeleted() {
|
||||
|
||||
+2
-2
@@ -11,8 +11,8 @@ import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
public interface RoleRepository extends JpaRepository<Role, Long>, JpaSpecificationExecutor<Role> {
|
||||
|
||||
@Query("SELECT COUNT(*) FROM AppUser a JOIN a.roles r WHERE r.id = :roleId")
|
||||
|
||||
@Query("SELECT COUNT(*) FROM AppUser a JOIN a.roles r WHERE r.id = :roleId AND a.deleted = false")
|
||||
Integer getCountOfRolesAssociatedWithUsers(@Param("roleId") Long roleId);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user