-
Notifications
You must be signed in to change notification settings - Fork 37
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
SWC-7081: pass the invitation token to One Sage #5525
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
package org.sagebionetworks.web.client.place.users; | ||
|
||
import com.google.gwt.place.shared.Place; | ||
import com.google.gwt.place.shared.PlaceTokenizer; | ||
import com.google.gwt.place.shared.Prefix; | ||
import org.sagebionetworks.web.client.place.ParameterizedPlace; | ||
|
||
public class RegisterAccount extends Place { | ||
public class RegisterAccount extends ParameterizedPlace { | ||
|
||
private String token; | ||
public static final String EMAIL_QUERY_PARAM = "email"; | ||
public static final String MEMBERSHIP_INVTN_QUERY_PARAM = | ||
"membershipInvtnSignedToken"; | ||
|
||
public RegisterAccount(String token) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that there are cases in the codebase that point to RegisterAccount with a default token ("0"). I tested that the presenter just redirects to the OneSage registration page without any additional query params (besides the appId used to brand the One Sage site) |
||
this.token = token; | ||
} | ||
|
||
public String toToken() { | ||
return token; | ||
super(token); | ||
} | ||
|
||
@Prefix("RegisterAccount") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,22 +21,21 @@ public void start(AcceptsOneWidget panel, EventBus eventBus) {} | |
|
||
@Override | ||
public void setPlace(RegisterAccount place) { | ||
String token = place.toToken(); | ||
if (token != null && token.contains("@")) { | ||
// is likely an email address | ||
Window.Location.replace( | ||
WebConstants.ONESAGE_PRODUCTION_URL + | ||
"/register1?email=" + | ||
token + | ||
"&" + | ||
WebConstants.ONESAGE_SYNAPSE_APPID_QUERY_PARAM | ||
); | ||
} else { | ||
Window.Location.replace( | ||
WebConstants.ONESAGE_PRODUCTION_URL + | ||
"/register1?" + | ||
WebConstants.ONESAGE_SYNAPSE_APPID_QUERY_PARAM | ||
); | ||
String emailInvitationToken = place.getParam( | ||
RegisterAccount.MEMBERSHIP_INVTN_QUERY_PARAM | ||
); | ||
String email = place.getParam(RegisterAccount.EMAIL_QUERY_PARAM); | ||
StringBuilder targetUrl = new StringBuilder(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Build up the target URL based on what parameters we have |
||
targetUrl.append(WebConstants.ONESAGE_PRODUCTION_URL); | ||
targetUrl.append("/register1?"); | ||
targetUrl.append(WebConstants.ONESAGE_SYNAPSE_APPID_QUERY_PARAM); | ||
|
||
if (emailInvitationToken != null) { | ||
targetUrl.append("&signedToken=" + emailInvitationToken); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where the magic happens. One Sage already has logic to read a signed token from the query parameters and store it in Local Storage. Then on the Account Created page, it already has logic to read this token in, check if it's of this type, and even automatically joins the target team (as well as changing the link to say something like "Take me to the Team"!). This workflow functions perfectly (I just tested it), once we send over this signed token! |
||
} | ||
if (email != null) { | ||
targetUrl.append("&email=" + email); | ||
} | ||
Window.Location.replace(targetUrl.toString()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -280,7 +280,14 @@ public void testNotLoggedIn() { | |
RegisterAccount.class | ||
); | ||
verify(mockPlaceChanger).goTo(captor.capture()); | ||
assertEquals("[email protected]", captor.getValue().toToken()); | ||
assertEquals( | ||
"[email protected]", | ||
captor.getValue().getParam(RegisterAccount.EMAIL_QUERY_PARAM) | ||
); | ||
assertEquals( | ||
encodedMISignedToken, | ||
captor.getValue().getParam(RegisterAccount.MEMBERSHIP_INVTN_QUERY_PARAM) | ||
); | ||
} | ||
|
||
@Test | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to a parameterized place so we can pass both the email and the signed token to the register account page (which will be passed to One Sage)