mirror of
https://github.com/QingWei-Li/notea.git
synced 2024-12-04 20:32:36 +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) {
|
||||
const { password } = credentials
|
||||
|
||||
if (password !== getEnv('PASSWORD')) {
|
||||
if (password !== getEnv<string>('PASSWORD').toString()) {
|
||||
return null
|
||||
}
|
||||
|
||||
console.log('ok')
|
||||
|
||||
return {
|
||||
logged: true,
|
||||
}
|
||||
|
@ -1,24 +1,19 @@
|
||||
import { GetServerSideProps } from 'next'
|
||||
import { getSession } from 'next-auth/client'
|
||||
import { useSession } from 'next-auth/client'
|
||||
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) => {
|
||||
const session = await getSession(ctx)
|
||||
if (loading) return null
|
||||
|
||||
if (!session) {
|
||||
return {
|
||||
redirect: {
|
||||
destination: '/api/auth/signin',
|
||||
permanent: false,
|
||||
},
|
||||
}
|
||||
if (!loading && !session) {
|
||||
router.push('/api/auth/signin')
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
props: {},
|
||||
}
|
||||
return <Layout></Layout>
|
||||
}
|
||||
|
||||
export default IndexPage
|
||||
|
@ -1,5 +1,3 @@
|
||||
import IndexPage, { getServerSideProps } from '..'
|
||||
|
||||
export { getServerSideProps }
|
||||
import IndexPage from '..'
|
||||
|
||||
export default IndexPage
|
||||
|
Loading…
Reference in New Issue
Block a user