From 07d2047afe85df818f0c5770ef224a07f0195b9e Mon Sep 17 00:00:00 2001 From: bsourisse Date: Tue, 18 Apr 2023 18:10:17 +0200 Subject: [PATCH] update: getServerSession is now stable for NextAuth --- pages/account/index.js | 4 ++-- pages/api/account/getAppriseAlert.js | 4 ++-- pages/api/account/getAppriseMode.js | 4 ++-- pages/api/account/getAppriseServices.js | 4 ++-- pages/api/account/getEmailAlert.js | 4 ++-- pages/api/account/sendTestApprise.js | 4 ++-- pages/api/account/sendTestEmail.js | 4 ++-- pages/api/account/updateAppriseAlert.js | 4 ++-- pages/api/account/updateAppriseMode.js | 4 ++-- pages/api/account/updateAppriseServices.js | 4 ++-- pages/api/account/updateEmail.js | 4 ++-- pages/api/account/updateEmailAlert.js | 4 ++-- pages/api/account/updatePassword.js | 4 ++-- pages/api/account/updateUsername.js | 4 ++-- pages/api/auth/[...nextauth].js | 2 +- pages/api/repo/add.js | 4 ++-- pages/api/repo/id/[slug]/delete.js | 4 ++-- pages/api/repo/id/[slug]/displayDetails.js | 4 ++-- pages/api/repo/id/[slug]/edit.js | 4 ++-- pages/api/repo/id/[slug]/index.js | 4 ++-- pages/api/repo/index.js | 4 ++-- pages/index.js | 4 ++-- pages/login.js | 4 ++-- pages/manage-repo/add.js | 4 ++-- pages/manage-repo/edit/[slug].js | 4 ++-- pages/monitoring/index.js | 4 ++-- pages/setup-wizard/[slug].js | 4 ++-- 27 files changed, 53 insertions(+), 53 deletions(-) diff --git a/pages/account/index.js b/pages/account/index.js index e52a68b..2593fef 100644 --- a/pages/account/index.js +++ b/pages/account/index.js @@ -3,7 +3,7 @@ import Head from 'next/head'; import 'react-toastify/dist/ReactToastify.css'; import { useSession } from 'next-auth/react'; import { authOptions } from '../../pages/api/auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; //Components import UserSettings from '../../Containers/UserSettings/UserSettings'; @@ -29,7 +29,7 @@ export default function Account() { export async function getServerSideProps(context) { //Var - const session = await unstable_getServerSession( + const session = await getServerSession( context.req, context.res, authOptions diff --git a/pages/api/account/getAppriseAlert.js b/pages/api/account/getAppriseAlert.js index dcd2a41..9254934 100644 --- a/pages/api/account/getAppriseAlert.js +++ b/pages/api/account/getAppriseAlert.js @@ -2,12 +2,12 @@ import { promises as fs } from 'fs'; import path from 'path'; import { authOptions } from '../auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; export default async function handler(req, res) { if (req.method == 'GET') { //Verify that the user is logged in. - const session = await unstable_getServerSession(req, res, authOptions); + const session = await getServerSession(req, res, authOptions); if (!session) { res.status(401).json({ message: 'You must be logged in.' }); return; diff --git a/pages/api/account/getAppriseMode.js b/pages/api/account/getAppriseMode.js index d89c875..efd5b32 100644 --- a/pages/api/account/getAppriseMode.js +++ b/pages/api/account/getAppriseMode.js @@ -2,12 +2,12 @@ import { promises as fs } from 'fs'; import path from 'path'; import { authOptions } from '../auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; export default async function handler(req, res) { if (req.method == 'GET') { //Verify that the user is logged in. - const session = await unstable_getServerSession(req, res, authOptions); + const session = await getServerSession(req, res, authOptions); if (!session) { res.status(401).json({ message: 'You must be logged in.' }); return; diff --git a/pages/api/account/getAppriseServices.js b/pages/api/account/getAppriseServices.js index 6d40c66..56ce6ed 100644 --- a/pages/api/account/getAppriseServices.js +++ b/pages/api/account/getAppriseServices.js @@ -2,12 +2,12 @@ import { promises as fs } from 'fs'; import path from 'path'; import { authOptions } from '../auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; export default async function handler(req, res) { if (req.method == 'GET') { //Verify that the user is logged in. - const session = await unstable_getServerSession(req, res, authOptions); + const session = await getServerSession(req, res, authOptions); if (!session) { res.status(401).json({ message: 'You must be logged in.' }); return; diff --git a/pages/api/account/getEmailAlert.js b/pages/api/account/getEmailAlert.js index de04585..fe22025 100644 --- a/pages/api/account/getEmailAlert.js +++ b/pages/api/account/getEmailAlert.js @@ -2,12 +2,12 @@ import { promises as fs } from 'fs'; import path from 'path'; import { authOptions } from '../auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; export default async function handler(req, res) { if (req.method == 'GET') { //Verify that the user is logged in. - const session = await unstable_getServerSession(req, res, authOptions); + const session = await getServerSession(req, res, authOptions); if (!session) { res.status(401).json({ message: 'You must be logged in.' }); return; diff --git a/pages/api/account/sendTestApprise.js b/pages/api/account/sendTestApprise.js index 1ec8ec3..66e7b27 100644 --- a/pages/api/account/sendTestApprise.js +++ b/pages/api/account/sendTestApprise.js @@ -1,6 +1,6 @@ //Lib import { authOptions } from '../auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; import { promises as fs } from 'fs'; import path from 'path'; const { exec } = require('child_process'); @@ -8,7 +8,7 @@ const { exec } = require('child_process'); export default async function handler(req, res) { if (req.method == 'POST') { //Verify that the user is logged in. - const session = await unstable_getServerSession(req, res, authOptions); + const session = await getServerSession(req, res, authOptions); if (!session) { res.status(401).json({ message: 'You must be logged in.' }); return; diff --git a/pages/api/account/sendTestEmail.js b/pages/api/account/sendTestEmail.js index 417f197..3bf0ea9 100644 --- a/pages/api/account/sendTestEmail.js +++ b/pages/api/account/sendTestEmail.js @@ -1,13 +1,13 @@ //Lib import { authOptions } from '../auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; import nodemailerSMTP from '../../../helpers/functions/nodemailerSMTP'; import emailTest from '../../../helpers/templates/emailTest'; export default async function handler(req, res) { if (req.method == 'POST') { //Verify that the user is logged in. - const session = await unstable_getServerSession(req, res, authOptions); + const session = await getServerSession(req, res, authOptions); if (!session) { res.status(401).json({ message: 'You must be logged in.' }); return; diff --git a/pages/api/account/updateAppriseAlert.js b/pages/api/account/updateAppriseAlert.js index a3694f0..5a3487d 100644 --- a/pages/api/account/updateAppriseAlert.js +++ b/pages/api/account/updateAppriseAlert.js @@ -2,12 +2,12 @@ import { promises as fs } from 'fs'; import path from 'path'; import { authOptions } from '../auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; export default async function handler(req, res) { if (req.method == 'PUT') { //Verify that the user is logged in. - const session = await unstable_getServerSession(req, res, authOptions); + const session = await getServerSession(req, res, authOptions); if (!session) { res.status(401).json({ message: 'You must be logged in.' }); return; diff --git a/pages/api/account/updateAppriseMode.js b/pages/api/account/updateAppriseMode.js index b0fb03a..4b25802 100644 --- a/pages/api/account/updateAppriseMode.js +++ b/pages/api/account/updateAppriseMode.js @@ -2,12 +2,12 @@ import { promises as fs } from 'fs'; import path from 'path'; import { authOptions } from '../auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; export default async function handler(req, res) { if (req.method == 'PUT') { //Verify that the user is logged in. - const session = await unstable_getServerSession(req, res, authOptions); + const session = await getServerSession(req, res, authOptions); if (!session) { res.status(401).json({ message: 'You must be logged in.' }); return; diff --git a/pages/api/account/updateAppriseServices.js b/pages/api/account/updateAppriseServices.js index 16922e7..0fe463e 100644 --- a/pages/api/account/updateAppriseServices.js +++ b/pages/api/account/updateAppriseServices.js @@ -2,12 +2,12 @@ import { promises as fs } from 'fs'; import path from 'path'; import { authOptions } from '../auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; export default async function handler(req, res) { if (req.method == 'PUT') { //Verify that the user is logged in. - const session = await unstable_getServerSession(req, res, authOptions); + const session = await getServerSession(req, res, authOptions); if (!session) { res.status(401).json({ message: 'You must be logged in.' }); return; diff --git a/pages/api/account/updateEmail.js b/pages/api/account/updateEmail.js index a84b556..a042354 100644 --- a/pages/api/account/updateEmail.js +++ b/pages/api/account/updateEmail.js @@ -2,12 +2,12 @@ import { promises as fs } from 'fs'; import path from 'path'; import { authOptions } from '../auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; export default async function handler(req, res) { if (req.method == 'PUT') { //Verify that the user is logged in. - const session = await unstable_getServerSession(req, res, authOptions); + const session = await getServerSession(req, res, authOptions); if (!session) { res.status(401).json({ message: 'You must be logged in.' }); return; diff --git a/pages/api/account/updateEmailAlert.js b/pages/api/account/updateEmailAlert.js index 40dabdf..5f1361e 100644 --- a/pages/api/account/updateEmailAlert.js +++ b/pages/api/account/updateEmailAlert.js @@ -2,12 +2,12 @@ import { promises as fs } from 'fs'; import path from 'path'; import { authOptions } from '../auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; export default async function handler(req, res) { if (req.method == 'PUT') { //Verify that the user is logged in. - const session = await unstable_getServerSession(req, res, authOptions); + const session = await getServerSession(req, res, authOptions); if (!session) { res.status(401).json({ message: 'You must be logged in.' }); return; diff --git a/pages/api/account/updatePassword.js b/pages/api/account/updatePassword.js index 11f216e..ea8bcb1 100644 --- a/pages/api/account/updatePassword.js +++ b/pages/api/account/updatePassword.js @@ -3,12 +3,12 @@ import { hashPassword, verifyPassword } from '../../../helpers/functions/auth'; import { promises as fs } from 'fs'; import path from 'path'; import { authOptions } from '../auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; export default async function handler(req, res) { if (req.method == 'PUT') { //Verify that the user is logged in. - const session = await unstable_getServerSession(req, res, authOptions); + const session = await getServerSession(req, res, authOptions); if (!session) { res.status(401).json({ message: 'You must be logged in.' }); return; diff --git a/pages/api/account/updateUsername.js b/pages/api/account/updateUsername.js index 9dc29cd..e919872 100644 --- a/pages/api/account/updateUsername.js +++ b/pages/api/account/updateUsername.js @@ -2,12 +2,12 @@ import { promises as fs } from 'fs'; import path from 'path'; import { authOptions } from '../auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; export default async function handler(req, res) { if (req.method == 'PUT') { //Verify that the user is logged in. - const session = await unstable_getServerSession(req, res, authOptions); + const session = await getServerSession(req, res, authOptions); if (!session) { res.status(401).json({ message: 'You must be logged in.' }); return; diff --git a/pages/api/auth/[...nextauth].js b/pages/api/auth/[...nextauth].js index 9cf72ce..a5c4e77 100644 --- a/pages/api/auth/[...nextauth].js +++ b/pages/api/auth/[...nextauth].js @@ -5,7 +5,7 @@ import { verifyPassword } from '../../../helpers/functions/auth'; import fs from 'fs'; import path from 'path'; -////Use if need getServerSideProps and therefore unstable_getServerSession +////Use if need getServerSideProps and therefore getServerSession export const authOptions = { providers: [ CredentialsProvider({ diff --git a/pages/api/repo/add.js b/pages/api/repo/add.js index cfb63d8..b7fbc68 100644 --- a/pages/api/repo/add.js +++ b/pages/api/repo/add.js @@ -1,14 +1,14 @@ import { promises as fs } from 'fs'; import path from 'path'; import { authOptions } from '../../../pages/api/auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; const util = require('node:util'); const exec = util.promisify(require('node:child_process').exec); export default async function handler(req, res) { if (req.method == 'POST') { //Verify that the user is logged in. - const session = await unstable_getServerSession(req, res, authOptions); + const session = await getServerSession(req, res, authOptions); if (!session) { res.status(401).json({ message: 'You must be logged in.' }); return; diff --git a/pages/api/repo/id/[slug]/delete.js b/pages/api/repo/id/[slug]/delete.js index e87bf44..717028f 100644 --- a/pages/api/repo/id/[slug]/delete.js +++ b/pages/api/repo/id/[slug]/delete.js @@ -1,14 +1,14 @@ import { promises as fs } from 'fs'; import path from 'path'; import { authOptions } from '../../../auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; const util = require('node:util'); const exec = util.promisify(require('node:child_process').exec); export default async function handler(req, res) { if (req.method == 'DELETE') { //Verify that the user is logged in. - const session = await unstable_getServerSession(req, res, authOptions); + const session = await getServerSession(req, res, authOptions); if (!session) { res.status(401).json({ message: 'You must be logged in.' }); return; diff --git a/pages/api/repo/id/[slug]/displayDetails.js b/pages/api/repo/id/[slug]/displayDetails.js index fb84efb..a244306 100644 --- a/pages/api/repo/id/[slug]/displayDetails.js +++ b/pages/api/repo/id/[slug]/displayDetails.js @@ -1,12 +1,12 @@ import { promises as fs } from 'fs'; import path from 'path'; import { authOptions } from '../../../auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; export default async function handler(req, res) { if (req.method == 'PUT') { //Verify that the user is logged in. - const session = await unstable_getServerSession(req, res, authOptions); + const session = await getServerSession(req, res, authOptions); if (!session) { res.status(401).json({ message: 'You must be logged in.' }); return; diff --git a/pages/api/repo/id/[slug]/edit.js b/pages/api/repo/id/[slug]/edit.js index 2a7064b..1327ebe 100644 --- a/pages/api/repo/id/[slug]/edit.js +++ b/pages/api/repo/id/[slug]/edit.js @@ -1,14 +1,14 @@ import { promises as fs } from 'fs'; import path from 'path'; import { authOptions } from '../../../auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; const util = require('node:util'); const exec = util.promisify(require('node:child_process').exec); export default async function handler(req, res) { if (req.method == 'PUT') { //Verify that the user is logged in. - const session = await unstable_getServerSession(req, res, authOptions); + const session = await getServerSession(req, res, authOptions); if (!session) { res.status(401).json({ message: 'You must be logged in.' }); return; diff --git a/pages/api/repo/id/[slug]/index.js b/pages/api/repo/id/[slug]/index.js index 610bf7c..7462858 100644 --- a/pages/api/repo/id/[slug]/index.js +++ b/pages/api/repo/id/[slug]/index.js @@ -1,12 +1,12 @@ import { promises as fs } from 'fs'; import path from 'path'; import { authOptions } from '../../../auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; export default async function handler(req, res) { if (req.method == 'GET') { //Verify that the user is logged in. - const session = await unstable_getServerSession(req, res, authOptions); + const session = await getServerSession(req, res, authOptions); if (!session) { res.status(401).json({ message: 'You must be logged in.' }); return; diff --git a/pages/api/repo/index.js b/pages/api/repo/index.js index 704fb8d..4d350c6 100644 --- a/pages/api/repo/index.js +++ b/pages/api/repo/index.js @@ -1,12 +1,12 @@ import fs from 'fs'; import path from 'path'; import { authOptions } from '../../../pages/api/auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; export default async function handler(req, res) { if (req.method == 'GET') { //Verify that the user is logged in. - const session = await unstable_getServerSession(req, res, authOptions); + const session = await getServerSession(req, res, authOptions); if (!session) { // res.status(401).json({ message: 'You must be logged in.' }); res.status(401).end(); diff --git a/pages/index.js b/pages/index.js index 39b044b..95de8fe 100644 --- a/pages/index.js +++ b/pages/index.js @@ -1,6 +1,6 @@ //Lib import { authOptions } from '../pages/api/auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; import { useSession } from 'next-auth/react'; import Head from 'next/head'; @@ -32,7 +32,7 @@ export default function Index() { export async function getServerSideProps(context) { //Var - const session = await unstable_getServerSession( + const session = await getServerSession( context.req, context.res, authOptions diff --git a/pages/login.js b/pages/login.js index fc95662..50e2db6 100644 --- a/pages/login.js +++ b/pages/login.js @@ -5,7 +5,7 @@ import { useState } from 'react'; import { SpinnerDotted } from 'spinners-react'; import { useRouter } from 'next/router'; import { authOptions } from './api/auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; //Components import Error from '../Components/UI/Error/Error'; @@ -179,7 +179,7 @@ export default function Login() { export async function getServerSideProps(context) { //Var - const session = await unstable_getServerSession( + const session = await getServerSession( context.req, context.res, authOptions diff --git a/pages/manage-repo/add.js b/pages/manage-repo/add.js index ea01869..8e2576b 100644 --- a/pages/manage-repo/add.js +++ b/pages/manage-repo/add.js @@ -1,6 +1,6 @@ import RepoList from '../../Containers/RepoList/RepoList'; import { authOptions } from '../../pages/api/auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; export default function Add() { return ; @@ -8,7 +8,7 @@ export default function Add() { export async function getServerSideProps(context) { //Var - const session = await unstable_getServerSession( + const session = await getServerSession( context.req, context.res, authOptions diff --git a/pages/manage-repo/edit/[slug].js b/pages/manage-repo/edit/[slug].js index 7c4eeb4..3a7496a 100644 --- a/pages/manage-repo/edit/[slug].js +++ b/pages/manage-repo/edit/[slug].js @@ -1,6 +1,6 @@ import RepoList from '../../../Containers/RepoList/RepoList'; import { authOptions } from '../../../pages/api/auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; export default function Add() { return ; @@ -8,7 +8,7 @@ export default function Add() { export async function getServerSideProps(context) { //Var - const session = await unstable_getServerSession( + const session = await getServerSession( context.req, context.res, authOptions diff --git a/pages/monitoring/index.js b/pages/monitoring/index.js index 5df3a50..bd4225c 100644 --- a/pages/monitoring/index.js +++ b/pages/monitoring/index.js @@ -1,6 +1,6 @@ import Head from 'next/head'; import { authOptions } from '../../pages/api/auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; //Components import StorageUsedChartBar from '../../Containers/Monitoring/StorageUsedChartBar/StorageUsedChartBar'; @@ -47,7 +47,7 @@ export default function Monitoring() { export async function getServerSideProps(context) { //Var - const session = await unstable_getServerSession( + const session = await getServerSession( context.req, context.res, authOptions diff --git a/pages/setup-wizard/[slug].js b/pages/setup-wizard/[slug].js index 9d6d4bd..fbcb229 100644 --- a/pages/setup-wizard/[slug].js +++ b/pages/setup-wizard/[slug].js @@ -3,7 +3,7 @@ import SetupWizard from '../../Containers/SetupWizard/SetupWizard'; import { useRouter } from 'next/router'; import Head from 'next/head'; import { authOptions } from '../../pages/api/auth/[...nextauth]'; -import { unstable_getServerSession } from 'next-auth/next'; +import { getServerSession } from 'next-auth/next'; export default function SetupWizardStep() { ////Var @@ -22,7 +22,7 @@ export default function SetupWizardStep() { export async function getServerSideProps(context) { //Var - const session = await unstable_getServerSession( + const session = await getServerSession( context.req, context.res, authOptions