New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RA-1516 Added support to select the location from the userProperty in the Login Screen #47

Merged
merged 1 commit into from Aug 2, 2018

Conversation

Projects
None yet
2 participants
@suthagar23
Member

suthagar23 commented Jul 26, 2018

Description

This PR contains the changes to select the session location from userProperty in the login screen. It will be worked according to these following steps,

  1. It will check for the Global property(GP) called "referenceapplication.locationUserPropertyName".
  2. If the GP has the value, then it will hide the location selector from the login screen
  3. When users try to log in, it will fetch the location from the user property
  4. If the respected user doesn't have the required user property, then it will redirect to the usual login screen(with login selector) to select the location

image

image

Ticket

Ticket : https://issues.openmrs.org/browse/RA-1516

@@ -277,7 +316,8 @@ public String post(@RequestParam(value = "username", required = false) String us
//TODO limit login attempts by IP Address
pageRequest.getSession().setAttribute(SESSION_ATTRIBUTE_REDIRECT_URL, redirectUrl);
// Since the user is already authenticated without location, need to logout before redirecting
Context.logout();

This comment has been minimized.

@dkayiwa

dkayiwa Jul 26, 2018

Member

Why would we log out from a method that is supposed to handle log in?

@dkayiwa

dkayiwa Jul 26, 2018

Member

Why would we log out from a method that is supposed to handle log in?

This comment has been minimized.

@suthagar23

suthagar23 Jul 27, 2018

Member

Since I need to do the context.authenticate() before verifying the location restrictions. So if anything required isn't satisfied, then it will be redirected with the authenticated user. So the user should automatically log out from the system before the redirect.

@suthagar23

suthagar23 Jul 27, 2018

Member

Since I need to do the context.authenticate() before verifying the location restrictions. So if anything required isn't satisfied, then it will be redirected with the authenticated user. So the user should automatically log out from the system before the redirect.

@dkayiwa

This comment has been minimized.

Show comment
Hide comment
@dkayiwa

dkayiwa Jul 26, 2018

Member

We also prefer to attach screenshot on the ticket instead of pull request as per https://wiki.openmrs.org/display/docs/Pull+Request+Tips

Member

dkayiwa commented Jul 26, 2018

We also prefer to attach screenshot on the ticket instead of pull request as per https://wiki.openmrs.org/display/docs/Pull+Request+Tips

@suthagar23

This comment has been minimized.

Show comment
Hide comment
@suthagar23

suthagar23 Jul 27, 2018

Member

@dkayiwa I have attached the affected login screen to the ticket comment. Please have a look again.

Member

suthagar23 commented Jul 27, 2018

@dkayiwa I have attached the affected login screen to the ticket comment. Please have a look again.

}
}
catch (ContextAuthenticationException ex) {
if (log.isDebugEnabled())

This comment has been minimized.

This comment has been minimized.

@suthagar23

suthagar23 Jul 27, 2018

Member

Actually, this came from the existing code. Do you want me to remove this as well?

@suthagar23

suthagar23 Jul 27, 2018

Member

Actually, this came from the existing code. Do you want me to remove this as well?

@@ -23,4 +23,6 @@
public static final long PROCESS_HL7_TASK_INTERVAL = 5L;
public static final String LOCATION_USER_PROPERTY_NAME = "referenceapplication.locationUserPropertyName";

This comment has been minimized.

@dkayiwa

dkayiwa Jul 27, 2018

Member

After looking at the other pull request, i have noticed that you expect the user property to be named as locationUuid

In such a case, of what value is this global property?

@dkayiwa

dkayiwa Jul 27, 2018

Member

After looking at the other pull request, i have noticed that you expect the user property to be named as locationUuid

In such a case, of what value is this global property?

This comment has been minimized.

@suthagar23

suthagar23 Jul 27, 2018

Member

Using this Global property(name - referenceapplication.locationUserPropertyName), I want to fetch the userProperty Name(should be value of this GP). Then need to use this userPropertyName to fetch the location from the userProperty(should be value of that userProperty).

So in our module, I'm using "locationUuuid" as the userPropertyName to store the locationUuid. So setting "locationUuid" to this GP.

@suthagar23

suthagar23 Jul 27, 2018

Member

Using this Global property(name - referenceapplication.locationUserPropertyName), I want to fetch the userProperty Name(should be value of this GP). Then need to use this userPropertyName to fetch the location from the userProperty(should be value of that userProperty).

So in our module, I'm using "locationUuuid" as the userPropertyName to store the locationUuid. So setting "locationUuid" to this GP.

This comment has been minimized.

@dkayiwa

dkayiwa Jul 27, 2018

Member

If you know that the property will be named as "locationUuuid", then of what value is the gp?

@dkayiwa

dkayiwa Jul 27, 2018

Member

If you know that the property will be named as "locationUuuid", then of what value is the gp?

This comment has been minimized.

@suthagar23

suthagar23 Jul 27, 2018

Member

So can we move the locationUserProperty to a global property name as "locationbasedaccess.locationUserPropertyName"? So the userProperty name also will be fetched from the GP, and use that same value to this RefApp GP as well?

@suthagar23

suthagar23 Jul 27, 2018

Member

So can we move the locationUserProperty to a global property name as "locationbasedaccess.locationUserPropertyName"? So the userProperty name also will be fetched from the GP, and use that same value to this RefApp GP as well?

This comment has been minimized.

@dkayiwa

dkayiwa Jul 27, 2018

Member

What do you think? What are the pros and cons of either side?

@dkayiwa

dkayiwa Jul 27, 2018

Member

What do you think? What are the pros and cons of either side?

This comment has been minimized.

@suthagar23

suthagar23 Jul 27, 2018

Member

I think, We have already concluded this discussion 😄

@suthagar23

suthagar23 Jul 27, 2018

Member

I think, We have already concluded this discussion 😄

Boolean isLocationUserPropertyAvailable = isLocationUserPropertyAvailable(administrationService);
Object showLocation = pageRequest.getAttribute("showSessionLocations");
if(showLocation != null && showLocation.toString().equals("true")) {
// if the request contains a attribute as showSessionLocations, then ignore isLocationUserPropertyAvailable

This comment has been minimized.

@dkayiwa

dkayiwa Jul 27, 2018

Member

Confusing how showLocation is true and then you set is location user property available to false?

@dkayiwa

dkayiwa Jul 27, 2018

Member

Confusing how showLocation is true and then you set is location user property available to false?

This comment has been minimized.

@suthagar23

suthagar23 Jul 27, 2018

Member

if the URL has the parameter as "showSessionLocations" with value True, then we need to ignore the userProperty method(if exist or not). So simply setting isLocationUserPropertyAvailable=false to disable this feature to view the location selector in the login screen. (See the address bar of the browser in the attached images in the PR)

@suthagar23

suthagar23 Jul 27, 2018

Member

if the URL has the parameter as "showSessionLocations" with value True, then we need to ignore the userProperty method(if exist or not). So simply setting isLocationUserPropertyAvailable=false to disable this feature to view the location selector in the login screen. (See the address bar of the browser in the attached images in the PR)

This comment has been minimized.

@dkayiwa

dkayiwa Jul 27, 2018

Member

who sets the showSessionLocations parameter to true and when?

@dkayiwa

dkayiwa Jul 27, 2018

Member

who sets the showSessionLocations parameter to true and when?

This comment has been minimized.

@suthagar23

suthagar23 Jul 27, 2018

Member

When a user doesn't get the location userProperty, then it will redirect to the login page with showSessionLocations=true. So I'm checking this parameter to show/hide the location selector here. See this line - https://github.com/openmrs/openmrs-module-referenceapplication/pull/47/files#diff-bd998e9f6ec90d297ceba7fb14c2fe66R249

@suthagar23

suthagar23 Jul 27, 2018

Member

When a user doesn't get the location userProperty, then it will redirect to the login page with showSessionLocations=true. So I'm checking this parameter to show/hide the location selector here. See this line - https://github.com/openmrs/openmrs-module-referenceapplication/pull/47/files#diff-bd998e9f6ec90d297ceba7fb14c2fe66R249

if (Context.isAuthenticated() && Context.getUserContext().getAuthenticatedUser() != null) {
String locationUuid = Context.getUserContext().getAuthenticatedUser().getUserProperty(locationUserPropertyName);
if (StringUtils.isNotBlank(locationUuid)) {
sessionLocation = locationService.getLocationByUuid(locationUuid);

This comment has been minimized.

@dkayiwa

dkayiwa Jul 27, 2018

Member

What happens when the uuid is for a non existing location?

@dkayiwa

dkayiwa Jul 27, 2018

Member

What happens when the uuid is for a non existing location?

This comment has been minimized.

@suthagar23

suthagar23 Jul 27, 2018

Member

It will return the null object to the sessionLocation. So it might cause some issues to the next line.
Just added a fix to this problem. Please look at this line again @dkayiwa

@suthagar23

suthagar23 Jul 27, 2018

Member

It will return the null object to the sessionLocation. So it might cause some issues to the next line.
Just added a fix to this problem. Please look at this line again @dkayiwa

Suthagar23
RA-1516 Added support to select the location from the userProperty in…
… the Login Screen

RA-1516 Added support to select the location from the userProperty in the Login Screen

RA-1516 Added support to select the location from the userProperty in the Login Screen

RA-1516 Added support to select the location from the userProperty in the Login Screen

RA-1516 Added support to select the location from the userProperty in the Login Screen

RA-1516 Added support to select the location from the userProperty in the Login Screen

RA-1516 Added support to select the location from the userProperty in the Login Screen

RA-1516 Added support to select the location from the userProperty in the Login Screen

RA-1516 Added support to select the location from the userProperty in the Login Screen

RA-1516 Added support to select the location from the userProperty in the Login Screen

RA-1516 Added support to select the location from the userProperty in the Login Screen

RA-1516 Added support to select the location from the userProperty in the Login Screen

RA-1516 Added support to select the location from the userProperty in the Login Screen

RA-1516 Added support to select the location from the userProperty in the Login Screen

RA-1516 Added support to select the location from the userProperty in the Login Screen

RA-1516 Added support to select the location from the userProperty in the Login Screen

RA-1516 Added support to select the location from the userProperty in the Login Screen

Indention changes

Indention changes

Indention changes

Indention changes

Indention changes

Indention changes

Indention changes

Indention changes

Indention changes

Indention changes

Indention changes

Indention changes

Indention changes

LBAC-13 Added implementation to create RefApp location glopal property

Added changes

Added changes

Added changes

Added changes

Added changes

Added changes

Added changes

Added changes

Added changes

Added changes

Added changes

Added changes

Added changes

@dkayiwa dkayiwa merged commit 8d605a5 into openmrs:master Aug 2, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment