Skip to content

Commit

Permalink
Merge pull request #84 from kinde-oss/peter/v2-hot-fixes
Browse files Browse the repository at this point in the history
Peter/v2 hot fixes
  • Loading branch information
DaveOrDead authored Nov 6, 2023
2 parents ddb5cdb + 842b6ca commit 82b6f54
Show file tree
Hide file tree
Showing 8 changed files with 256 additions and 225 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kinde-oss/kinde-auth-nextjs",
"version": "2.0.0-alpha.2",
"version": "2.0.0",
"description": "Kinde Auth SDK for NextJS",
"main": "dist/cjs/index.js",
"module": "dist/index.js",
Expand Down
5 changes: 1 addition & 4 deletions src/authMiddleware/authMiddleware.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import jwt_decode from 'jwt-decode';
import {NextResponse} from 'next/server';
import {config} from '../config/index';
import {isTokenValid} from '../utils/pageRouter/isTokenValid';
Expand All @@ -10,11 +9,10 @@ export function authMiddleware(request) {
let isAuthenticated = false;
const nextUrl = trimTrailingSlash(request.nextUrl.href);
const logoutUrl = trimTrailingSlash(config.postLogoutRedirectURL);
const kinde_token = request.cookies.get('kinde_token');
const kinde_token = request.cookies.get('access_token');
const isLogoutUrl = nextUrl === logoutUrl;

if (kinde_token) {
const payload = jwt_decode(JSON.parse(kinde_token.value).access_token);
isAuthenticated = true;
}

Expand Down Expand Up @@ -49,7 +47,6 @@ const handleMiddleware = async (req, options, onSuccess) => {
config.redirectURL
)
);
response.headers.set('x-hello-from-middleware2', 'hello');
return response;
}

Expand Down
35 changes: 22 additions & 13 deletions src/config/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
import {GrantType} from '@kinde-oss/kinde-typescript-sdk';
import {version} from '../utils/version';

/**
* @type {import('../../types').KindeState}
*/
const initialState = {
user: null,
isLoading: true,
checkSession: null,
accessToken: null,
getClaim: null,
getFlag: null,
getToken: null,
getBooleanFlag: null,
getStringFlag: null,
getIntegerFlag: null,
getPermission: null,
getPermissions: null,
permissions: null,
idToken: null,
isAuthenticated: false,
isLoading: true,
organization: null,
userOrganizations: null
permissions: [],
user: null,
userOrganiaztions: [],
getAccessToken: () => null,
getBooleanFlag: () => null,
getClaim: () => null,
getFlag: () => null,
getIdToken: () => null,
getIntegerFlag: () => null,
getOrganization: () => null,
getPermission: () => null,
getPermissions: () => [],
getStringFlag: () => null,
getToken: () => null,
getUser: () => null,
getUserOrganizations: () => null
};

const SESSION_PREFIX = 'pkce-verifier';
Expand Down
Loading

0 comments on commit 82b6f54

Please sign in to comment.