import { WFAuth } from "@xatom/core";
// Initialize with generics: <UserType, RoleType, ConfigType>
const userAuth = new WFAuth<
{
fullName: string;
email: string;
},
"GUEST" | "USER",
{
token: string;
}
>();
// Basic usage flow
userAuth.setRole("GUEST");
console.log(userAuth.isLoggedIn()); // false
userAuth.setUser({
fullName: "John Doe",
email: "john@doe.com",
});
userAuth.setConfig({
token: "XYZ",
});
userAuth.setRole("USER");
console.log(userAuth.isLoggedIn()); // true
userAuth.logout();
console.log(userAuth.isLoggedIn()); // false