Skip to content

Commit

Permalink
poc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjmcgrath committed Sep 1, 2022
1 parent 269f8dd commit 2cf4015
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@auth0/nextjs-auth0",
"version": "1.9.1",
"version": "1.9.1-mw.5",
"description": "Next.js SDK for signing in with Auth0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -10,7 +10,8 @@
},
"files": [
"dist",
"src"
"src",
"middleware.js"
],
"engines": {
"node": "^10.13.0 || >=12.0.0"
Expand Down
5 changes: 5 additions & 0 deletions src/auth0-session/handlers/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export default function logoutHandlerFactory(
let returnURL = options.returnTo || config.routes.postLogoutRedirect;
debug('logout() with return url: %s', returnURL);

// @ts-ignore
await sessionCache.init(req);

if (url.parse(returnURL).host === null) {
returnURL = urlJoin(config.baseURL, returnURL);
}
Expand All @@ -35,6 +38,8 @@ export default function logoutHandlerFactory(

const idToken = sessionCache.getIdToken(req);
sessionCache.delete(req);
// @ts-ignore
await sessionCache.save(req, res);

if (!config.idpLogout) {
debug('performing a local only logout, redirecting to %s', returnURL);
Expand Down
2 changes: 2 additions & 0 deletions src/handlers/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export default function profileHandler(
try {
assertReqRes(req, res);

await sessionCache.init(req);

if (!sessionCache.isAuthenticated(req)) {
res.status(401).json({
error: 'not_authenticated',
Expand Down
2 changes: 1 addition & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ export const _initAuth = (params?: ConfigParameters): Instance => {

export const getSession: GetSession = (...args) => getInstance().getSession(...args);
export const withMiddlewareAuthRequired: WithMiddlewareAuthRequired = (
middleware: NextMiddleware,
middleware?: NextMiddleware,
params?: ConfigParameters
) => getInstance(params).withMiddlewareAuthRequired(middleware);

0 comments on commit 2cf4015

Please sign in to comment.