Skip to content

Self Service emails do not retain the goto or locale parameter #272

Closed

Description

@lscorcia

Describe the bug
The Self Service registration and password recovery can be configured to send an email verification link to the user, however in the outgoing email the return link is generated from a template that only takes into account the realm parameter, ignoring other parameters like the locale or the goto querystring value.

This is especially problematic when directing the user to the self-registration page, because after a successful registration the user will be redirected to his OpenAM console instead of the application he intended to register to.

To Reproduce
Steps to reproduce the behavior:

  1. Enable the User Self Service service, the User Registration feature and activate Email Verification
  2. Visit the User registration page including a goto parameter in the url (i.e. http://login.domain.com:8080/openam/XUI/?realm=/public&goto=https://www.google.com#register/ )
  3. Enter your Email address and continue. Note that the "Return to the login page" link still has the correct goto parameter value
  4. See error: Check the link in the email you received, notice that the goto parameter is missing
  5. Manually add the goto parameter to the link, open it in a browser and complete the registration process. After logging in you will be correctly redirected to the Google homepage, so the redirect is working, it's just the link that's not generated correctly.

Expected behavior
After a successful user registration, or any other self-service sequence, the user should be redirected to the value of the goto parameter, if present.

Additional context
The issue does not seem to be too complex, I will try to work on it.

Activity

  1. lscorcia commented on Mar 31, 2020

    @lscorcia
    ContributorAuthor

    This is far more complex than I imagined. The problem here is that the XUI never passes those querystring parameters to the self-service stages. The locale parameter can be inferred, because the Accept-Language http headers are set according to the user preferred locale, but for the goto parameter it's a whole another story, and thinking about it there's a bunch of other parameters which might be useful to preserve, i.e. service, module, etc.

    The easiest way might be to create a custom self service stage to capture the querystring parameters in a hidden field via JS and autosubmit the form immediately. The parameters could then be loaded into the stage context and be available for the email verification stage, however I'd hate to add yet-another-DOM-refresh to the process. Maybe I could incorporate this JS in the initial self service stages?

    I have found https://bugster.forgerock.org/jira/browse/OPENAM-9125 which seems to imply that this feature isn't implemented even in the most recent ForgeRock AM release (isn't that a bit crazy? It has been open for years and to me this seems an extremely important feature!).

    Anyway, this was just an update. I will keep trying...

  2. added 2 commits that reference this issue on Apr 7, 2020
    5ae1767
    cd2e40e
  3. lscorcia commented on Apr 7, 2020

    @lscorcia
    ContributorAuthor

    Thank you @vharseko ! Could you please update submodules?

  4. vharseko commented on Apr 7, 2020

    @vharseko
    Member
    [INFO] -------------------------------------------------------
    [INFO]  T E S T S
    [INFO] -------------------------------------------------------
    [INFO] Running TestSuite
    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
    [ERROR] Tests run: 98, Failures: 3, Errors: 0, Skipped: 0, Time elapsed: 0.997 s <<< FAILURE! - in TestSuite
    [ERROR] testAdvanceCallbackSendMail(org.forgerock.selfservice.stages.email.VerifyEmailAccountStageTest)  Time elapsed: 0.013 s  <<< FAILURE!
    java.lang.NullPointerException
    	at org.forgerock.selfservice.stages.email.VerifyEmailAccountStageTest.testAdvanceCallbackSendMail(VerifyEmailAccountStageTest.java:180)
    
    [ERROR] testAdvanceInitialStage(org.forgerock.selfservice.stages.email.VerifyEmailAccountStageTest)  Time elapsed: 0.001 s  <<< FAILURE!
    java.lang.NullPointerException
    	at org.forgerock.selfservice.stages.email.VerifyEmailAccountStageTest.testAdvanceInitialStage(VerifyEmailAccountStageTest.java:127)
    
    [ERROR] testGatherInitialRequirementsWithEmailInContext(org.forgerock.selfservice.stages.email.VerifyEmailAccountStageTest)  Time elapsed: 0.004 s  <<< FAILURE!
    java.lang.AssertionError: 
    
    Expecting empty but was:<{"$schema"="http://json-schema.org/draft-04/schema#", "description"="Verify your email address", "properties"={"querystringParams"={"description"="Querystring params", "type"="hidden"}}, "type"="object"}>
    	at org.forgerock.selfservice.stages.email.VerifyEmailAccountStageTest.testGatherInitialRequirementsWithEmailInContext(VerifyEmailAccountStageTest.java:104)
    
    [INFO] 
    [INFO] Results:
    [INFO] 
    [ERROR] Failures: 
    [ERROR]   VerifyEmailAccountStageTest.testAdvanceCallbackSendMail:180 » NullPointer
    [ERROR]   VerifyEmailAccountStageTest.testAdvanceInitialStage:127 » NullPointer
    [ERROR]   VerifyEmailAccountStageTest.testGatherInitialRequirementsWithEmailInContext:104 
    Expecting empty but was:<{"$schema"="http://json-schema.org/draft-04/schema#", "description"="Verify your email address", "properties"={"querystringParams"={"description"="Querystring params", "type"="hidden"}}, "type"="object"}>
    [INFO] 
    [ERROR] Tests run: 98, Failures: 3, Errors: 0, Skipped: 0
    
  5. lscorcia commented on Apr 7, 2020

    @lscorcia
    ContributorAuthor

    I'm so sorry! I'll take a look at it immediately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions