Skip to content

Commit 477f758

Browse files
HTML-796 Auto select location if only one is available. (#101)
Co-authored-by: Pedro Sousa <psousa@icrc.org>
1 parent 8fdfff5 commit 477f758

2 files changed

Lines changed: 1 addition & 23 deletions

File tree

omod/src/main/java/org/openmrs/module/referenceapplication/page/controller/LoginPageController.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,7 @@ public String post(@RequestParam(value = "username", required = false) String us
275275
if (sessionLocation == null) {
276276
List<Location> loginLocations = appFrameworkService.getLoginLocations();
277277
if (loginLocations.size() == 1) {
278-
if (!ui.convertTimezones() || (ui.convertTimezones() && !clientTimezoneProperty)) {
279-
sessionLocation = loginLocations.get(0);
280-
}
281-
278+
sessionLocation = loginLocations.get(0);
282279
}
283280
}
284281

omod/src/test/java/org/openmrs/module/referenceapplication/page/controller/LoginPageControllerTest.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -647,23 +647,4 @@ public void post_shouldAutoSelectALocationAfterAuthenticationIfLoginLocationsSiz
647647
verify(sessionContext, times(1)).setSessionLocation(eq(location));
648648
}
649649

650-
@Test
651-
public void post_shouldNotAutoSelectALocationAfterAuthenticationIfLoginLocationsSizeIsOneAndUsingTimezonesWithoutClientTimezone() throws Exception {
652-
when(Context.isAuthenticated()).thenReturn(false).thenReturn(true);
653-
when(Context.getAuthenticatedUser()).thenReturn(mock(User.class));
654-
final int LOCATION_ID = 1;
655-
final String LOCATION_SELECTION_PAGE = "redirect:/openmrs/" + ReferenceApplicationConstants.MODULE_ID + "/login.page";
656-
PageRequest pageRequest = createPageRequest(new MockHttpServletRequest(), null);
657-
658-
Location location = new Location(LOCATION_ID);
659-
location.addTag(new LocationTag(EmrApiConstants.LOCATION_TAG_SUPPORTS_LOGIN, null));
660-
when(appFrameworkService.getLoginLocations()).thenReturn(Collections.singletonList(location));
661-
when(administrationService.getGlobalProperty(eq(ReferenceApplicationConstants.LOCATION_USER_PROPERTY_NAME)))
662-
.thenReturn("someValue");
663-
664-
assertEquals(LOCATION_SELECTION_PAGE, new LoginPageController().post(USERNAME, PASSWORD, null, null, locationService,
665-
administrationService, uiUtilsWithTimezone, appFrameworkService, pageRequest, sessionContext));
666-
667-
}
668-
669650
}

0 commit comments

Comments
 (0)