Skip to content

Commit a60dacd

Browse files
fixed(auth.context): use constant instead of string toke l. storage
1 parent 7d315f0 commit a60dacd

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules
33
dist
44
dist-ssr
55
*.local
6+
.idea

src/contexts/auth.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function AuthProvider({children}: AuthProvider) {
3333
try {
3434
const response = await AuthService.singIn(githubCode);
3535
const {token, user} = response.data;
36-
localStorage.setItem(LOCAL_STORAGE_TOKEN_USER_NAME, token);
36+
localStorage.setItem(LOCAL_STORAGE_TOKEN_USER_NAME, token);
3737
setUser(user);
3838
} catch (error) {
3939
console.error(error);
@@ -52,15 +52,15 @@ export function AuthProvider({children}: AuthProvider) {
5252

5353
function singOut() {
5454
setUser(null);
55-
localStorage.removeItem('@dowhile:token')
55+
localStorage.removeItem(LOCAL_STORAGE_TOKEN_USER_NAME)
5656
}
5757

5858
useEffect(() => getGithubCodeFromQueryString(), []);
5959

6060
useEffect(() => loadUserFromLocalStorageWhenExists(), []);
6161

6262
return (
63-
<AuthContext.Provider value={{singOut: singOut, user: user,}}>
63+
<AuthContext.Provider value={{singOut, user}}>
6464
{children}
6565
</AuthContext.Provider>
6666
);

0 commit comments

Comments
 (0)