Skip to content
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

feat(admin-next): Email password invite flow in admin 2.0 #6821

Merged
merged 4 commits into from
Mar 29, 2024

Conversation

olivermrbl
Copy link
Contributor

@olivermrbl olivermrbl commented Mar 25, 2024

Add invite flow for email-password auth provider

CleanShot.2024-03-27.at.09.56.31.mp4

To test it out, you need the latest changes from develop, in which invite support has been added to our CLI.

Then do:

  1. Run admin dashboard: cd packages/admin-next/dashboard && yarn run dev
  2. Start your Medusa project (that has latest changes)
  3. Run the following command in your Medusa project: medusa user -e [email protected] --invite
  4. Copy token from terminal output
  5. Access the invite URL in admin: http://localhost:5173/invite?token=[token]
  6. Accept the invite

Copy link

changeset-bot bot commented Mar 25, 2024

⚠️ No Changeset found

Latest commit: 16b1b5e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Mar 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 28, 2024 10:38am
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Mar 28, 2024 10:38am
docs-ui ⬜️ Ignored (Inspect) Visit Preview Mar 28, 2024 10:38am
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Mar 28, 2024 10:38am

@olivermrbl olivermrbl marked this pull request as ready for review March 27, 2024 09:01
@olivermrbl olivermrbl requested a review from a team as a code owner March 27, 2024 09:01
@olivermrbl olivermrbl changed the title feat(admin-next): Invite flow feat(admin-next): Email password invite flow in admin 2.0 Mar 27, 2024
<LogoBox
className="mb-4"
checked={success}
containerTransition={{
Copy link
Member

Choose a reason for hiding this comment

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

Probably not something for now, but a general comment: It's much better to encapsulate and standardize transitions and animations, both for consistency in appearance, as well as simplfying the code. As you can see now, half of the JSX is animation config. cc @kasperkristensen WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 think that we could have something as <Fade direction= "up" /> or at least easing functions in the UI lib

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we want to address such things in UI for v2, or should we wait till after?

And if so, do we know where we want to place these?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would define these in medusajs/ui but probably not necessary for v2 atm

Copy link
Contributor

Choose a reason for hiding this comment

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

If the animation is ever re-used I think it would make sense to move it to a file in @medusajs/dashboard, but it's a one off animation, so don't see a reason to move it into a separate file atm. Feel free to move it to a const outside of the JSX for better readability though.

And I would prefer to not move any framer logic into @medusajs/ui. We don't use Framer in the project, only a small number of CSS animations. If people want to add animations on top of that they can then use framer or their preferred animation component, but I don't think it should be something that is built-in, or force people to use a specific animation library ✌️

Copy link
Member

Choose a reason for hiding this comment

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

@kasperkristensen it doesn't necessarily need to be part of medusajs/ui, it can be a separate animations folder in the admin, but my point is that it would be nice to see what is extractable. And definitely not urgent for v2, just a general comment after looking at the code.

Copy link
Contributor

@fPolic fPolic left a comment

Choose a reason for hiding this comment

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

NIce 💪
Left a few comments.

<LogoBox
className="mb-4"
checked={success}
containerTransition={{
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 think that we could have something as <Fade direction= "up" /> or at least easing functions in the UI lib

@olivermrbl
Copy link
Contributor Author

@fPolic, could I get you to give this another review?

@fPolic
Copy link
Contributor

fPolic commented Mar 28, 2024

On it @olivermrbl 👀

@fPolic
Copy link
Contributor

fPolic commented Mar 28, 2024

The main flow works nicely!

However, I've noticed 2 issues:

  1. If you try to reuse the same invite link twice -> it won't create an account but the flow will look like everything is OK (should we check if the invite token is used already?)

  2. The other odd issue, probably not directly related to your PR is that when you try to log in with email/pass that doesn't exist....it will create a new record in auth_user table

@olivermrbl
Copy link
Contributor Author

If you try to reuse the same invite link twice -> it won't create an account but the flow will look like everything is OK (should we check if the invite token is used already?)

Did you accept it with a different email + password or the same as the first time?

The other odd issue, probably not directly related to your PR is that when you try to log in with email/pass that doesn't exist....it will create a new record in auth_user table

This is actually intended behaviour and part of our new auth flow. Funny enough, I just had a discussed with Seb on how to address this in our docs. Probably could have a cron job cleaning up unused auth users on a fixed schedule, but we'll let that be up to users to decide

@fPolic
Copy link
Contributor

fPolic commented Mar 28, 2024

Did you accept it with a different email + password or the same as the first time?

I used a different email.

This is actually intended behaviour and part of our new auth flow.

Ahh alright 😅 I thought that might be intentional but wanted to check.

@olivermrbl
Copy link
Contributor Author

"Issue" with double-accepting invites resolved internally. We failed to reproduce, so will keep it as is.

@olivermrbl olivermrbl merged commit d97af91 into develop Mar 29, 2024
24 checks passed
@olivermrbl olivermrbl deleted the feat/invites-v2 branch March 29, 2024 07:05
gempain added a commit to gempain/medusa that referenced this pull request Mar 29, 2024
gempain added a commit to gempain/medusa that referenced this pull request Mar 29, 2024
sradevski added a commit that referenced this pull request Mar 29, 2024
* fix(inventory): cannot migrate existing products (#6877)

* chore: add changeset (#6821)

---------

Co-authored-by: Geoffroy Empain <[email protected]>
Co-authored-by: Stevche Radevski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants