-
Notifications
You must be signed in to change notification settings - Fork 25
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
Support RR7 & remix-auth@4 #54
base: main
Are you sure you want to change the base?
Conversation
Great work on this! I am also blocked on migrating until these changes are in so I appreciate the initiative |
@pbteja1998 can we get a review on this? 🙏 |
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.
Awesome work! Thanks for getting the ball rolling on this
// remove the magic link and email from the session | ||
session.unset(this.sessionMagicLinkKey) | ||
session.unset(this.sessionEmailKey) | ||
session.unset('magicLink') |
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.
couple of observations here:
- it looks like the ability to set one's own keys for the cookie storage is no longer available? This feels like a regression in my opinion
- to minimize breaking changes we should leave the default values as is e.g. auth:magiclink
session.flash(this.sessionErrorKey, { message }) | ||
const cookie = await sessionStorage.commitSession(session) | ||
throw redirect(options.failureRedirect, { | ||
session.flash('error', message) |
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.
any reason you're choosing to flash the message text directly as opposed to within an object?
@@ -197,24 +235,15 @@ export class EmailLinkStrategy<User> extends Strategy< | |||
|
|||
// This should only be called in an action if it's used to start the login process | |||
if (request.method === 'POST') { | |||
if (!options.successRedirect) { |
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.
would it not be useful to keep successRedirect as optional? It can be useful to defer the redirect to the app's business logic. In my apps I have the following for my verify loader:
const { email, name, isAdmin } = await auth.authenticate(
"email-link",
request,
{
failureRedirect: "/auth/login",
},
);
const session = await getSession(request.headers.get("Cookie"));
const redirectBackTo = session.get("auth:loginDestination");
// set the session for a logged in/verified guest user
session.set("user", { email, name, isAdmin });
session.set("isGuest", true);
session.set("emailSubscription", true);
session.unset("auth:email");
session.unset("auth:link");
session.unset("auth:loginDestination");
return redirect(redirectBackTo ?? "/", {
headers: {
"Set-Cookie": await commitSession(session),
},
});
Hello @pbteja1998 !
This package is great and wanted it to port to remix-auth@4 along with React Router 7 (latest Remix). Following are the significant changes to remix-auth@4
remix
isreact-router
. So Removed allremix
dependenciessessionStorage
andoptions
is not passed inauthenticate
function nowsessionStorage
in the constructor optionskeys
as I am defining the types specificallytsconfig.json
as perreact-router
specificationpackage-lock.json