-
Notifications
You must be signed in to change notification settings - Fork 365
Expand file tree
/
Copy pathuserStore.js
More file actions
32 lines (22 loc) · 864 Bytes
/
userStore.js
File metadata and controls
32 lines (22 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { create } from "zustand";
const useUserStore = create((set) => ({
userId: "",
setUserId: (userId) => set({ userId }),
name: "",
setName: (name) => set({ name }),
username: "",
setUsername: (username) => set({ username }),
avatarUrl: "",
setUserAvatarUrl: (avatarUrl) => set(() => ({ avatarUrl })),
isUserAuthenticated: false,
setIsUserAuthenticated: (isUserAuthenticated) => set(() => ({ isUserAuthenticated })),
// SECURITY FIX (Issue #1263): Removed password storage from global state
// Passwords should never be stored in client-side state (CWE-312)
emailoruser: null,
setEmailorUser: (emailoruser) => set(() => ({ emailoruser })),
showAvatar: false,
setShowAvatar: (showAvatar) => set(() => ({ showAvatar })),
roles: {},
setRoles: (roles) => set((state) => ({ ...state, roles })),
}));
export default useUserStore;