feat(intial auth): intial auth setup for the scanner
Some checks failed
Build and Push LST Docker Image / docker (push) Has been cancelled
Some checks failed
Build and Push LST Docker Image / docker (push) Has been cancelled
This commit is contained in:
28
lstMobile/src/hooks/useMobileAuth.ts
Normal file
28
lstMobile/src/hooks/useMobileAuth.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { create } from "zustand";
|
||||
|
||||
type MobileUser = {
|
||||
id: string;
|
||||
name: string;
|
||||
role: "user" | "lead" | "manager" | "admin";
|
||||
excludedCommand: string[];
|
||||
};
|
||||
|
||||
type AuthState = {
|
||||
user: MobileUser | null;
|
||||
isUnlocked: boolean;
|
||||
|
||||
setUser: (user: MobileUser) => void;
|
||||
lock: () => void;
|
||||
logout: () => void;
|
||||
};
|
||||
|
||||
export const useMobileAuthStore = create<AuthState>((set) => ({
|
||||
user: null,
|
||||
isUnlocked: false,
|
||||
|
||||
setUser: (user) => set({ user, isUnlocked: true }),
|
||||
|
||||
lock: () => set({ isUnlocked: false }),
|
||||
|
||||
logout: () => set({ user: null, isUnlocked: false }),
|
||||
}));
|
||||
Reference in New Issue
Block a user