diff --git a/pom.xml b/pom.xml
index bced9f9c1..3f7ca80b2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
opensrp-server-web
war
- 3.2.11-SNAPSHOT
+ 3.2.12-SNAPSHOT
opensrp-server-web
OpenSRP Server Web Application
https://github.com/OpenSRP/opensrp-server-web
@@ -25,7 +25,7 @@
6.1.6.RELEASE
always
1.5.1
- 3.2.8-SNAPSHOT
+ 3.2.9-ALPHA1-SNAPSHOT
2.4.1-SNAPSHOT
2.0.1-SNAPSHOT
2.0.5
diff --git a/src/main/java/org/opensrp/web/controller/UserController.java b/src/main/java/org/opensrp/web/controller/UserController.java
index dd16e057d..fbae13d14 100644
--- a/src/main/java/org/opensrp/web/controller/UserController.java
+++ b/src/main/java/org/opensrp/web/controller/UserController.java
@@ -51,7 +51,6 @@
import org.opensrp.service.PractitionerService;
import org.opensrp.web.exceptions.MissingTeamAssignmentException;
import org.opensrp.web.rest.RestUtils;
-import org.slf4j.LoggerFactory;
import org.smartregister.domain.Jurisdiction;
import org.smartregister.domain.PhysicalLocation;
import org.smartregister.domain.PlanDefinition.PlanStatus;
@@ -201,14 +200,19 @@ public ResponseEntity authenticate(Authentication authentication) throws
try {
String userId = u.getBaseEntityId();
practionerOrganizationIds = practitionerService.getOrganizationsByUserId(userId);
-
- for (AssignedLocations assignedLocation : organizationService
- .findAssignedLocationsAndPlans(practionerOrganizationIds.right)) {
- if (StringUtils.isNotBlank(assignedLocation.getJurisdictionId()))
- locationIds.add(assignedLocation.getJurisdictionId());
- if (StringUtils.isNotBlank(assignedLocation.getPlanId()))
- planIdentifiers.add(assignedLocation.getPlanId());
- }
+
+ if (practionerOrganizationIds != null && practionerOrganizationIds.right.size() > 0) {
+ for (AssignedLocations assignedLocation : organizationService
+ .findAssignedLocationsAndPlans(practionerOrganizationIds.right)) {
+ if (StringUtils.isNotBlank(assignedLocation.getJurisdictionId()))
+ locationIds.add(assignedLocation.getJurisdictionId());
+ if (StringUtils.isNotBlank(assignedLocation.getPlanId()))
+ planIdentifiers.add(assignedLocation.getPlanId());
+ }
+ } else {
+ throw new MissingTeamAssignmentException(
+ "User not mapped on any location. Make sure that user is assigned to an organization with valid Location(s) ");
+ }
jurisdictions.addAll(locationService.findLocationByIdsWithChildren(false, locationIds, Integer.MAX_VALUE));