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

docs: with-remix-tpep_example #797

Closed
wants to merge 42 commits into from
Closed

Conversation

mawentowski
Copy link

@mawentowski mawentowski commented Mar 7, 2024

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:

  • Update Remix sections to match the updated Remix app
  • Fix code samples and ensure they pass type checking.

Checklist for important updates

  • Changelog has been updated
  • frontendDriverInterfaceSupported.json file has been updated (if needed)
  • Changes to the version if needed
    • In package.json
    • In package-lock.json
    • In lib/ts/version.ts
  • Had run npm run build-pretty
  • Had installed and ran the pre-commit hook
  • Issue this PR against the latest non released version branch.
    • To know which one it is, run find the latest released tag (git tag) in the format vX.Y.Z, and then find the latest branch (git branch --all) whose X.Y is greater than the latest released tag.
    • If no such branch exists, then create one from the latest released branch.
  • If added a new recipe interface, then make sure that the implementation of it uses NON arrow functions only (like someFunc: function () {..}).- [ ] If I added a new recipe, I also added the recipe entry point into the size-limit section of package.json with the size limit set to the current size rounded up.
  • If I added a new recipe, I also added the recipe entry point into the rollup.config.mjs

Copy link

github-actions bot commented Mar 7, 2024

size-limit report 📦

Path Size
lib/build/index.js 14.43 KB (0%)
recipe/session/index.js 15.34 KB (0%)
recipe/session/prebuiltui.js 18.08 KB (0%)
recipe/thirdpartyemailpassword/index.js 30.22 KB (0%)
recipe/thirdparty/index.js 26.85 KB (0%)
recipe/emailpassword/index.js 10.29 KB (0%)
recipe/emailverification/index.js 7.52 KB (0%)
recipe/passwordless/index.js 63.96 KB (0%)
recipe/thirdpartypasswordless/index.js 83.98 KB (0%)
recipe/emailverification/prebuiltui.js 22.63 KB (0%)
recipe/thirdpartyemailpassword/prebuiltui.js 53.92 KB (0%)
recipe/thirdparty/prebuiltui.js 38.75 KB (0%)
recipe/emailpassword/prebuiltui.js 28.03 KB (0%)
recipe/passwordless/prebuiltui.js 102.84 KB (0%)
recipe/thirdpartypasswordless/prebuiltui.js 129.84 KB (0%)
recipe/multitenancy/index.js 6.34 KB (0%)

@mawentowski mawentowski changed the title Docs/with remix tpep example Add remix example Mar 7, 2024
@mawentowski mawentowski changed the title Add remix example docs: with-remix-tpep_example Mar 7, 2024
.github/workflows/test-examples.yml Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
examples/with-remix-thirdpartyemailpassword/README.md Outdated Show resolved Hide resolved
examples/with-remix-thirdpartyemailpassword/package.json Outdated Show resolved Hide resolved
examples/with-remix-thirdpartyemailpassword/server.mjs Outdated Show resolved Hide resolved
@rishabhpoddar rishabhpoddar changed the base branch from 0.38 to 0.39 March 14, 2024 07:21
Comment on lines 81 to 84
return {
session: null,
error: error instanceof Error ? error : new Error(String(error)),
};
Copy link
Contributor

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

Copy link
Author

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 {
Copy link
Contributor

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

Copy link
Author

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 = {
Copy link
Contributor

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

Copy link
Author

@mawentowski mawentowski Mar 15, 2024

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">
Copy link
Contributor

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!

Copy link
Author

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");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const cookieHeader = request.headers.get("Cookie");
const cookieHeader = request.cookies

return query;
}

function createPreParsedRequest(request: Request): PreParsedRequest {
Copy link
Contributor

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

Copy link
Author

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({
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

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>
);
}

Copy link
Author

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.

@DBozhinovski
Copy link
Contributor

Covered by: #809
Example ported to create-supertokes-app and generalized to cover all auth options -> supertokens/create-supertokens-app#98

@rishabhpoddar rishabhpoddar deleted the docs/with-remix-tpep_example branch March 21, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants