Skip to content

Conversation

@binh-dam-ibigroup
Copy link
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup commented Sep 8, 2020

This PR adds a link to resend an email verification message hooked to the proper OTP middleware endpoint.

To test, use the backend code from ibi-group/otp-middleware#95.

image

@binh-dam-ibigroup binh-dam-ibigroup added the BLOCKED Blocked (waiting on another PR to be merged) label Sep 8, 2020
@binh-dam-ibigroup
Copy link
Collaborator Author

Blocking because ibi-group/otp-middleware#71.

@binh-dam-ibigroup binh-dam-ibigroup changed the title feat(VerifyEmailScreen): Add link to resend verification email. Add link to resend verification email. Sep 8, 2020
@binh-dam-ibigroup binh-dam-ibigroup marked this pull request as ready for review November 5, 2020 23:26
@binh-dam-ibigroup binh-dam-ibigroup removed the BLOCKED Blocked (waiting on another PR to be merged) label Nov 5, 2020
<Button
bsSize='large'
bsStyle='primary'
onClick={this._handleClick}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there are now 2 buttons, can this handler be renamed to something more specific?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Updated in 7152d27.

Copy link
Contributor

@evansiroky evansiroky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved assuming the 1 small change I requested is implemented.

@binh-dam-ibigroup binh-dam-ibigroup removed their assignment Nov 6, 2020
export function resendVerificationEmail (auth0) {
return async function (dispatch, getState) {
const { apiBaseUrl, apiKey } = getMiddlewareVariables(getState())
const accessToken = await auth0.getAccessTokenSilently()
Copy link
Member

@landonreed landonreed Nov 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't accessToken stored in the reducer now? See line 123 above. My initial impression is that we should not be passing auth0 to this method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accessToken is not stored yet because it is set that the same time as the user, and the user didn't get set yet. Should that get split?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm not sure. Perhaps we should split the set access token functionality out from set logged in user. What do you think about having an additional check in UserLoaderScreen that checks if accessToken is available from the store? If not, it can just call auth0.getAccessTokenSilently() and store it. That would allow us to then fetch or initialize user without passing auth0.

// UserLoaderScreen
componentDidUpdate () {
    const { accessToken, auth0, fetchOrInitializeUser, setAccessToken } = this.props
    if (!accessToken) {
      let token = await auth0.getAccessTokenSilently()
      setAccessToken({accessToken: token, auth0User: auth0.user})
    }
    if (accessToken && this.loggedInUserIsUnfetched()) {
      fetchOrInitializeUser() // can now get accessToken and auth0User from store
    }
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@landonreed let me think what you think of this: b9b0ba3. We still need the auth0 argument to initialize a default user (needs the auth0 id and email).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good to me. But resendVerificationEmail no longer needs the auth0 param now, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Updated in 77a1a2c.

<DivSpacer>
Please check your email inbox and follow the link in the message
to verify your email address before finishing your account setup.
</DivSpacer>
Copy link
Member

@landonreed landonreed Nov 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to use a p tag here. It should have some margin at the bottom.

Copy link
Member

@landonreed landonreed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but can we grab accessToken similar to the other methods?

* If absent, state.user.accessToken will be used for fetches.
* @param auth0 If provided, the auth0 login object used to initialize the default user object (with email and auth0 id).
*/
export function fetchOrInitializeUser (auth0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this arg should be changed to auth0User.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about auth0Context? Because the actual auth0 user is in auth0.user, which is passed to method createNewUser.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 77a1a2c to auth0User.

Copy link
Member

@landonreed landonreed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, conditional approval after addressing a couple of final comments.

Remove auth0 as arg for resendVerificationEmail; change arg of fetchOrInitializeUser to auth0User;
cleanup.
@binh-dam-ibigroup binh-dam-ibigroup merged commit a87a72a into dev Nov 14, 2020
@binh-dam-ibigroup binh-dam-ibigroup deleted the resend-verif-email branch November 14, 2020 00:09
@evansiroky evansiroky mentioned this pull request Nov 20, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2021

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants