-
Notifications
You must be signed in to change notification settings - Fork 91
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
docs: with-remix-tpep_example #797
Conversation
size-limit report 📦
|
examples/with-remix-thirdpartyemailpassword/app/routes/api.auth.$.tsx
Outdated
Show resolved
Hide resolved
examples/with-remix-thirdpartyemailpassword/app/routes/api.auth.$.tsx
Outdated
Show resolved
Hide resolved
examples/with-remix-thirdpartyemailpassword/app/routes/api.auth.$.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Rishabh Poddar <[email protected]>
Co-authored-by: Rishabh Poddar <[email protected]>
Co-authored-by: Rishabh Poddar <[email protected]>
Co-authored-by: Rishabh Poddar <[email protected]>
return { | ||
session: null, | ||
error: error instanceof Error ? error : new Error(String(error)), | ||
}; |
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.
this is not corect. There are many reasons getSession can throw, and some of them require you to refresh the session. Please see how the nextjs integration works
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.
The NextJS-based logic has been added to the Home component, i.e., if statements for when an error occurs, there is no active session/access token, etc.
|
||
export type HTTPMethod = "post" | "get" | "delete" | "put" | "options" | "trace"; | ||
|
||
export interface ExtendedSession extends SessionContainerInterface { |
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.
why is this type needed? The session
object being returned from getSession has the type of SessionContainerInterface
which is good enough
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.
Removed.
@@ -0,0 +1,48 @@ | |||
import { SessionContainerInterface } from "supertokens-node/lib/build/recipe/session/types"; | |||
|
|||
export type PartialRemixRequest = { |
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.
do we really need this type? Think of a way in which it's not needed
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.
Refactored, so this type isn't needed.
|
||
<div className="truncate userId">{session.userId}</div> | ||
return ( | ||
<div className="homeContainer"> |
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.
this needs to be wrapped around in component from our react SDK. See the nextjs integration please!
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.
It is now wrapped in a <SessionAuthForRemix>
component.
|
||
function getCookieFromRequest(request: Request) { | ||
const cookies: Record<string, string> = {}; | ||
const cookieHeader = request.headers.get("Cookie"); |
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.
const cookieHeader = request.headers.get("Cookie"); | |
const cookieHeader = request.cookies |
return query; | ||
} | ||
|
||
function createPreParsedRequest(request: Request): PreParsedRequest { |
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.
this function can go in a file like supertokensHelper, and then you don't need it here, nor do you need it in the middleware file
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.
Moved this function into the separate file as suggested.
}); | ||
} | ||
|
||
export async function loader({ |
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.
this should be same as the https://github.com/supertokens/supertokens-node/blob/master/lib/ts/nextjs.ts#L142
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.
The functionality you mentioned has been incorporated into the superTokensHelpers.ts
, in the getSessionDetails
function, which is called from the loader.
</div> | ||
); | ||
} | ||
|
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.
In the logic below, after logging in, deleting the access token and refreshing always redirects to /auth
instead of refreshing the session.
Covered by: #809 |
Summary of change
I added a demo Remix app for the third-party email password recipe to the
examples
folder. Also included is a basic test file based on the with-emailpassword-vercel example. Since the example project uses modules, and basic.test.js needs to be treated like a CommonJS module, I changed the file extension to basic.test.cjs and updated the test-examples workflow to support running CJS files.Documentation changes
Documentation changes will come in a subsequent PR to the docs repo. The changes that need to occur are as follows:
Checklist for important updates
frontendDriverInterfaceSupported.json
file has been updated (if needed)package.json
package-lock.json
lib/ts/version.ts
npm run build-pretty
git tag
) in the formatvX.Y.Z
, and then find the latest branch (git branch --all
) whoseX.Y
is greater than the latest released tag.someFunc: function () {..}
).- [ ] If I added a new recipe, I also added the recipe entry point into thesize-limit
section ofpackage.json
with the size limit set to the current size rounded up.rollup.config.mjs