mirror of
https://github.com/Ravinou/borgwarehouse
synced 2024-05-08 08:36:38 +02:00
Merge pull request #36 from Ravinou/update-nextAuth-method
update: getServerSession is now stable for NextAuth
This commit is contained in:
commit
cc54d0d6ba
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <RepoList />;
|
||||
|
@ -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
|
||||
|
|
|
@ -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 <RepoList />;
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue