diff --git a/CHANGELOG.md b/CHANGELOG.md index 67ce42d..e058e56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### [v1.1.2](https://github.com/kinde-oss/kinde-remix-sdk/compare/v1.1.1...v1.1.2) +> 6 September 2024 + +- chore: release v1.1.2 [`6af02f4`](https://github.com/kinde-oss/kinde-remix-sdk/commit/6af02f465478d9c06d1cdaf691fc371c8fa353c4) + #### [v1.1.1](https://github.com/kinde-oss/kinde-remix-sdk/compare/v1.1.0...v1.1.1) > 28 August 2024 diff --git a/src/handle-auth.js b/src/handle-auth.js index d8720dd..e2fe199 100644 --- a/src/handle-auth.js +++ b/src/handle-auth.js @@ -104,10 +104,7 @@ export const handleAuth = async (request, route, options) => { "Set your post login redirect URL in your environment variables."; const headers = generateCookieHeader(request, cookies); - /** - * @type {any} - */ - const user = await sessionManager.getSessionItem("user"); + const user = await kindeClient.getUser(sessionManager); options?.onRedirectCallback?.({ user }); diff --git a/tests/handle-auth.test.ts b/tests/handle-auth.test.ts index 2bfe14d..242dcdc 100644 --- a/tests/handle-auth.test.ts +++ b/tests/handle-auth.test.ts @@ -13,7 +13,7 @@ describe("handleAuth", () => { it("should handle login requests", async () => { const requestEvent = new Request( - "http://localhost/oop/?returnTo=/redirect", + "http://localhost/oop/?returnTo=/redirect" ); const loginMock = vi.fn().mockImplementation(async () => { @@ -33,7 +33,7 @@ describe("handleAuth", () => { it("should handle register requests", async () => { const requestEvent = new Request( - "http://localhost/oop/?returnTo=/redirect", + "http://localhost/oop/?returnTo=/redirect" ); const registerMock = vi.fn().mockImplementation(async () => { @@ -71,11 +71,24 @@ describe("handleAuth", () => { const callback = vi.fn().mockImplementation(async () => { return new URL("http://localhost/logged-out"); }); + + const getUserMock = vi.fn().mockImplementation(async () => { + return { + family_name: "Test", + given_name: "Tom", + picture: + "https://lh3.googleusercontent.com/a/ACg8ocLSV5BzAauEPx7KiftgzBclIOZN7AGwr-Yp194XPMaCEqAr0e3e=s96-c", + email: "peterphanouvong@gmail.com", + id: "kp:a912075d0172416787920727ddcf087e", + }; + }); + kindeClient.handleRedirectToApp = callback; + kindeClient.getUser = getUserMock; const res = await handleAuth(requestEvent, "callback"); expect(res?.status).toBe(302); expect(res?.headers.get("location")).toBe( - "http://localhost:3000/test-login", + "http://localhost:3000/test-login" ); }); });