mirror of
https://github.com/QingWei-Li/notea.git
synced 2024-12-06 02:32:58 +03:00
fix: remove getServerSideProps
This commit is contained in:
parent
1a20c4b290
commit
467f7a8950
@ -17,10 +17,12 @@ export default (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
async authorize(credentials) {
|
async authorize(credentials) {
|
||||||
const { password } = credentials
|
const { password } = credentials
|
||||||
|
|
||||||
if (password !== getEnv('PASSWORD')) {
|
if (password !== getEnv<string>('PASSWORD').toString()) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('ok')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
logged: true,
|
logged: true,
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,19 @@
|
|||||||
import { GetServerSideProps } from 'next'
|
import { useSession } from 'next-auth/client'
|
||||||
import { getSession } from 'next-auth/client'
|
|
||||||
import { Layout } from 'components/layout'
|
import { Layout } from 'components/layout'
|
||||||
|
import { useRouter } from 'next/router'
|
||||||
|
|
||||||
const IndexPage = () => <Layout></Layout>
|
const IndexPage = () => {
|
||||||
|
const [session, loading] = useSession()
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
if (loading) return null
|
||||||
const session = await getSession(ctx)
|
|
||||||
|
|
||||||
if (!session) {
|
if (!loading && !session) {
|
||||||
return {
|
router.push('/api/auth/signin')
|
||||||
redirect: {
|
return null
|
||||||
destination: '/api/auth/signin',
|
|
||||||
permanent: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return <Layout></Layout>
|
||||||
props: {},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default IndexPage
|
export default IndexPage
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import IndexPage, { getServerSideProps } from '..'
|
import IndexPage from '..'
|
||||||
|
|
||||||
export { getServerSideProps }
|
|
||||||
|
|
||||||
export default IndexPage
|
export default IndexPage
|
||||||
|
Loading…
Reference in New Issue
Block a user