Question
Nielsen
US
Last activity: 4 Aug 2016 23:16 EDT
How to read Extra Parameter during Log In
Hi -
In out application we need to ensure that User logs in by clicking on a link that he received via email.
This URL should have an extra parameter say "User_Key" .
When the user clicks on this link he is is routed to the Pega Login page .He has to enter his credentials and click on log in. On log in I need to compare the User Key with a value stored in Pega Data.
I Customized the IAC Authentication Service to call an activity which extracts this values.
However in the activity I cannot retrieve the value of User_Key when user clicks on login (even though User_key) exists in the URL.
I can get the value of User_Key if I refresh the link but not on click of Log In Button.
In my activity I retrieve the value using :
@java("((javax.servlet.http.HttpServletRequest)tools.getRequestor().getRequestorPage().getObject(\"pxHTTPServletRequest\")).getParameter(\"UserKey\")")
Can you let me know how we can retrieve this value on click of the Log In Button.
Also I need to save this value to DB, but Pega throws an exception when I try to Open the Data Page because at this point authentication is not complete yet.
How can I save this value to DB after the user Authenticates?
Thank you.
***Updated by moderator: Lochan to add Category***
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Pegasystems Inc.
US
Hi,
With regards to the parameter you're accessing the parameter correctly in your activity but the parameter will get dropeed when you display the login screen.
The form element in the default Web-Login HTML record does NOT add the query string:
<form name="main" method="post" onSubmit="return sendLoginRequestForm(event);" action="<pega:reference name="pxThread.pxReqURI" mode="normal" />" target="_top" novalidate="novalidate" autocomplete="off" >
The first time the login activity runs you have it configured to display the login screen. Unless you use the pyQueryString parameter to map to the clipboard and then add them to the login screen the parameters will get dropped. When the user fills in thier user credential and hits submit the activity is run again but your parameters are no longer there.
With PRCustom authentication there is a pyQueryString parameter that contains all the parameters. This needs to get mapped to the clipboard on the first execution of the activity where the parameters were sent in.
The sample configuration I have outlined below is going to make sure the login screen always submits the initial query string as well. You can follow this if you want or modify for your needs. For example you could just to step 3 and 4. The general idea is you need to capture the initial query string content for later use as the login activity runs multiple times.
Step1:
Hi,
With regards to the parameter you're accessing the parameter correctly in your activity but the parameter will get dropeed when you display the login screen.
The form element in the default Web-Login HTML record does NOT add the query string:
<form name="main" method="post" onSubmit="return sendLoginRequestForm(event);" action="<pega:reference name="pxThread.pxReqURI" mode="normal" />" target="_top" novalidate="novalidate" autocomplete="off" >
The first time the login activity runs you have it configured to display the login screen. Unless you use the pyQueryString parameter to map to the clipboard and then add them to the login screen the parameters will get dropped. When the user fills in thier user credential and hits submit the activity is run again but your parameters are no longer there.
With PRCustom authentication there is a pyQueryString parameter that contains all the parameters. This needs to get mapped to the clipboard on the first execution of the activity where the parameters were sent in.
The sample configuration I have outlined below is going to make sure the login screen always submits the initial query string as well. You can follow this if you want or modify for your needs. For example you could just to step 3 and 4. The general idea is you need to capture the initial query string content for later use as the login activity runs multiple times.
Step1:
Copy Web-Login - Rename to WebLoginSSO. (Make sure this is in a RuleSet that is available to unautheticated users, same ruleset where you have your activity customizations will work)
Step 2:
Update you authentication service, custom tab, reference WebLoginSSO as the Credential Challenge Stream.
Step 3:
Add new property to Code-Pega-Thread.SSOSnapStartQuery. (Unauthenticated RuleSet)
Step 4:
Update your login activity and set the SSOSnapStartQuery property to the param.pyQueryString. You do this at the bottom of the activity before you direct to display the login screen the first time the activity is run.
Step 5:
Update the WebLoginSSO and mapp the SSOSnapStartQuery into the form element action attribute. Bold/Italic is the code changes.
<body onload="processOnLoad()" oncontextmenu="return false;">
<%
String actionURL = tools.findPage("pxThread").getString("pxReqURI");
String SSOSnapStartQuery = tools.findPage("pxThread").getString("SSOSnapStartQuery");
oLog.infoForced("SSOSnapStartQuery in login page: " + SSOSnapStartQuery);
if (SSOSnapStartQuery != null && SSOSnapStartQuery.length() > 0)
{
actionURL += "?" + SSOSnapStartQuery;
}
tools.putParamValue("actionURL", com.pega.pegarules.pub.util.StringUtils.urlCrossScriptingFilter(actionURL));
%>
<pega:choose>
<pega:when test="DisableAutoComplete" >
<form name="main" method="post" onSubmit="return sendLoginRequestForm(event);" action="<pega:reference name="param.actionURL" mode="normal" />" target="_top" novalidate="novalidate" autocomplete="off" >
</pega:when>
<pega:otherwise>
<form name="main" method="post" onSubmit="return sendLoginRequestForm(event);" action="<pega:reference name="param.actionURL" mode="normal" />" novalidate="novalidate" target="_top" >
</pega:otherwise>
With regards to saving the parameter value to the DB during login. You have to give permissions within the AccessGroup used for unauthenticated users to be able to save the the PRPC class. So, you need to define a standard role that will give permission to save to the class and make sure it's defined in the AccessGroup for the unauthenticated users.
Note: You just have to issue a Obj-Save. The commit will occur at the engine level once operator verification has completed as the system is updating and commiting the operator record.
Pegasystems Inc.
IN
Hi
Have you tried customizing the log in button as well ? Refer this : https://docs-previous.pega.com/customizing-pega-7-login-screen
May be it is a good idea to chcek whether you can pass on the parameter via this button click .
Accepted Solution
Pegasystems Inc.
US
Hi,
With regards to the parameter you're accessing the parameter correctly in your activity but the parameter will get dropeed when you display the login screen.
The form element in the default Web-Login HTML record does NOT add the query string:
<form name="main" method="post" onSubmit="return sendLoginRequestForm(event);" action="<pega:reference name="pxThread.pxReqURI" mode="normal" />" target="_top" novalidate="novalidate" autocomplete="off" >
The first time the login activity runs you have it configured to display the login screen. Unless you use the pyQueryString parameter to map to the clipboard and then add them to the login screen the parameters will get dropped. When the user fills in thier user credential and hits submit the activity is run again but your parameters are no longer there.
With PRCustom authentication there is a pyQueryString parameter that contains all the parameters. This needs to get mapped to the clipboard on the first execution of the activity where the parameters were sent in.
The sample configuration I have outlined below is going to make sure the login screen always submits the initial query string as well. You can follow this if you want or modify for your needs. For example you could just to step 3 and 4. The general idea is you need to capture the initial query string content for later use as the login activity runs multiple times.
Step1:
Hi,
With regards to the parameter you're accessing the parameter correctly in your activity but the parameter will get dropeed when you display the login screen.
The form element in the default Web-Login HTML record does NOT add the query string:
<form name="main" method="post" onSubmit="return sendLoginRequestForm(event);" action="<pega:reference name="pxThread.pxReqURI" mode="normal" />" target="_top" novalidate="novalidate" autocomplete="off" >
The first time the login activity runs you have it configured to display the login screen. Unless you use the pyQueryString parameter to map to the clipboard and then add them to the login screen the parameters will get dropped. When the user fills in thier user credential and hits submit the activity is run again but your parameters are no longer there.
With PRCustom authentication there is a pyQueryString parameter that contains all the parameters. This needs to get mapped to the clipboard on the first execution of the activity where the parameters were sent in.
The sample configuration I have outlined below is going to make sure the login screen always submits the initial query string as well. You can follow this if you want or modify for your needs. For example you could just to step 3 and 4. The general idea is you need to capture the initial query string content for later use as the login activity runs multiple times.
Step1:
Copy Web-Login - Rename to WebLoginSSO. (Make sure this is in a RuleSet that is available to unautheticated users, same ruleset where you have your activity customizations will work)
Step 2:
Update you authentication service, custom tab, reference WebLoginSSO as the Credential Challenge Stream.
Step 3:
Add new property to Code-Pega-Thread.SSOSnapStartQuery. (Unauthenticated RuleSet)
Step 4:
Update your login activity and set the SSOSnapStartQuery property to the param.pyQueryString. You do this at the bottom of the activity before you direct to display the login screen the first time the activity is run.
Step 5:
Update the WebLoginSSO and mapp the SSOSnapStartQuery into the form element action attribute. Bold/Italic is the code changes.
<body onload="processOnLoad()" oncontextmenu="return false;">
<%
String actionURL = tools.findPage("pxThread").getString("pxReqURI");
String SSOSnapStartQuery = tools.findPage("pxThread").getString("SSOSnapStartQuery");
oLog.infoForced("SSOSnapStartQuery in login page: " + SSOSnapStartQuery);
if (SSOSnapStartQuery != null && SSOSnapStartQuery.length() > 0)
{
actionURL += "?" + SSOSnapStartQuery;
}
tools.putParamValue("actionURL", com.pega.pegarules.pub.util.StringUtils.urlCrossScriptingFilter(actionURL));
%>
<pega:choose>
<pega:when test="DisableAutoComplete" >
<form name="main" method="post" onSubmit="return sendLoginRequestForm(event);" action="<pega:reference name="param.actionURL" mode="normal" />" target="_top" novalidate="novalidate" autocomplete="off" >
</pega:when>
<pega:otherwise>
<form name="main" method="post" onSubmit="return sendLoginRequestForm(event);" action="<pega:reference name="param.actionURL" mode="normal" />" novalidate="novalidate" target="_top" >
</pega:otherwise>
With regards to saving the parameter value to the DB during login. You have to give permissions within the AccessGroup used for unauthenticated users to be able to save the the PRPC class. So, you need to define a standard role that will give permission to save to the class and make sure it's defined in the AccessGroup for the unauthenticated users.
Note: You just have to issue a Obj-Save. The commit will occur at the engine level once operator verification has completed as the system is updating and commiting the operator record.
Nielsen
US
Hi - Thank you for the help. I am able to get the URL parameter in the Login Activity now. I still could not save the Data Page while in the activity . It could be a problem with modifying the access groups incorrectly .
Thank you again.
Regards,
Smitha
Nielsen
US
Hi -
I am still not able to save the parameter in the activity using an OBJ-SAVE. I had raised another question for it , the data page I need to save belongs in the application rulest. (Say , MyAPP-FW 1.0.0 )
While doing a custom authentication I am setting the operator an access group which provides access to MyApp-FW
However still Pega gives me an error in the logs stating "
You are not authorized to save instance MyApp-FW ...."
I would like to also know if there is another way of doing this after login but before user gets the pega home page.
Thanks,
Smitha Rajasenan