Skip to content

Commit 1dbbbca

Browse files
Fixed auth provider hook.
1 parent d6ae7f2 commit 1dbbbca

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

hooks/useAuth.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
11
// hooks/useAuth.ts
2-
import { useContext } from "react";
3-
import { AuthContext } from "@/providers/AuthProvider";
2+
import { useContext } from 'react';
3+
import { AuthContext } from '@/providers/AuthProvider';
44

55
export interface AuthUser {
6-
idToken: string;
7-
user: {
8-
id: string;
9-
name: string | null;
10-
email: string;
11-
photo: string | null;
12-
familyName: string | null;
13-
givenName: string | null;
14-
};
6+
idToken: string;
7+
accessToken?: string;
8+
refreshToken?: string;
9+
user: {
10+
id: string;
11+
name: string | null;
12+
email: string;
13+
photo: string | null;
14+
familyName: string | null;
15+
givenName: string | null;
16+
};
1517
}
1618

1719
export type AuthContextType = {
18-
user: AuthUser | null;
19-
setUser: React.Dispatch<React.SetStateAction<AuthUser | null>>;
20+
user: AuthUser | null;
21+
setUser: React.Dispatch<React.SetStateAction<AuthUser | null>>;
2022
};
2123

2224
export function useAuth(): AuthContextType {
23-
const ctx = useContext(AuthContext);
24-
if (!ctx) {
25-
throw new Error("useAuth must be used within <AuthProvider>");
26-
}
27-
return ctx;
25+
const ctx = useContext(AuthContext);
26+
if (!ctx) {
27+
throw new Error('useAuth must be used within <AuthProvider>');
28+
}
29+
return ctx;
2830
}

0 commit comments

Comments
 (0)