BLUE
PHP 7.4.33
Path:
/var/www/web-koncept/client/src/context
Run
Logout
Edit File
Size: 840 B
Close
/var/www/web-koncept/client/src/context/AuthContext.js
Text
Base64
import { createContext, useReducer } from "react"; export const AuthContext = createContext(); export const authReducer = (state, action) => { switch (action.type) { case "LOGIN": return { user: action.payload, access_token: action.token }; case "LOGOUT": localStorage.removeItem("user"); localStorage.removeItem("token"); return { user: null, access_token: null }; default: return state; } }; export const AuthContextProvider = ({ children }) => { const [state, dispatch] = useReducer(authReducer, { user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : null, access_token: localStorage.getItem("token") || null, }); return ( <AuthContext.Provider value={{ ...state, dispatch }}> {children} </AuthContext.Provider> ); };
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 2
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
AuthContext.js
840 B
lrw-r--r--
2024-11-04 12:03:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DataContext.js
1.68 KB
lrw-r--r--
2024-11-06 05:16:11
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).