By: Sthitaprajna Das named 11 Nov 2019 at 8:27 a.m. CST

1 Response
Sthitaprajna Das gravatar
Hi, We are trying to set a variable in custom login.xhtml page as below. We could not identify how to set in the html so we did it in java script. <script type="text/javascript"> window.onload = function () { #{identity.setWorkingParameter('ip_param', data.ip)}; ip = #{identity.getWorkingParameter('ip_param')}; alert('ip is:'+ip); }; </script> When we run , the javascript is not able to recognize below line. #{identity.setWorkingParameter('ip_param', data.ip)}; Kindly let us know how we can achieve above. Later we want to fetch this parameter in our authentication interception script. Basically the need is to pass a value to interception script from the the login page. Thanks, Sthita

By Aliaksandr Samuseu staff 11 Nov 2019 at 2:39 p.m. CST

Aliaksandr Samuseu gravatar
Hi, Sthitaprajna. Perhaps you could provide more details on what you are trying to achieve, so it would be easier to suggest a solution? For now, I'll relay a few suggestions from my colleagues on the dev team they provided in our internal chat: This approach: ``` ip = #{identity.getWorkingParameter('ip_param')}; ``` ...will hardly work, and isn't the standard way to pass some parameter back to the custom script (please correct me, but this seems like what you're trying to do). Normally, you just want to add a new field to the form you POST back to the script when an user is done with the page - and then handle it appropriately in there (for example, receive the form with your parameter in it and choose whether to advance to the next step, go back, or repeat this one if needed - now taking into account the new parameter's value). Also, if your goal is to learn ip address of an user, it all may be redundant as you can get this information from session's and/or request's context in the script itself, as exemplified in [this line of supergluu script](https://github.com/GluuFederation/oxAuth/blob/master/Server/integrations/super_gluu/SuperGluuExternalAuthenticator.py#L987). Hope this helps.