diff --git a/src/routes/docs/tutorials/nextjs/step-4/+page.markdoc b/src/routes/docs/tutorials/nextjs/step-4/+page.markdoc index 202b4ead8c..a37e6f2c45 100644 --- a/src/routes/docs/tutorials/nextjs/step-4/+page.markdoc +++ b/src/routes/docs/tutorials/nextjs/step-4/+page.markdoc @@ -26,13 +26,13 @@ Create a new file `hooks/useAuth.ts` and add the following code. // hooks/useAuth.ts import { useState, useEffect } from 'react'; -import { account } from '../lib/appwrite'; +import { account } from '@/lib/appwrite'; import { ID } from 'appwrite'; import type { Models } from 'appwrite'; import { useRouter } from 'next/navigation'; export function useAuth() { - const [current, setCurrent] = useState(null); + const [current, setCurrent] = useState | null>(null); const [loading, setLoading] = useState(true); const router = useRouter(); @@ -46,16 +46,17 @@ export function useAuth() { }; const login = async (email: string, password: string): Promise => { - const session = await account.createEmailPasswordSession({ + await account.createEmailPasswordSession({ email, password }); - setCurrent(session); + const user = await account.get(); + setCurrent(user); router.push('/'); }; const logout = async (): Promise => { - await account.deleteSession('current'); + await account.deleteSession({ sessionId: 'current' }); setCurrent(null); router.push('/'); }; @@ -97,7 +98,7 @@ We will define functions to handle form submissions and show either a signup or 'use client'; import { useState } from 'react'; -import { useAuth } from '../../hooks/useAuth'; +import { useAuth } from '@/hooks/useAuth'; import AuthForm from '../../components/AuthForm'; export default function LoginPage() { diff --git a/src/routes/docs/tutorials/nextjs/step-5/+page.markdoc b/src/routes/docs/tutorials/nextjs/step-5/+page.markdoc index b896f49b77..35ea71a071 100644 --- a/src/routes/docs/tutorials/nextjs/step-5/+page.markdoc +++ b/src/routes/docs/tutorials/nextjs/step-5/+page.markdoc @@ -18,7 +18,7 @@ Create a new file `src/components/Navbar.tsx` and add the code below. 'use client'; import Link from 'next/link'; -import { useAuth } from '../hooks/useAuth'; +import { useAuth } from '@/hooks/useAuth'; export default function Navbar() { const { current, logout } = useAuth(); @@ -28,7 +28,7 @@ export default function Navbar() {

Idea Tracker

{current ? (
-

{current.providerUid}

+

{current.name || current.email}

- {user && user.userId === idea.userId && ( + {user && user.$id === idea.userId && (