first implementation
This commit is contained in:
parent
79458bcba4
commit
870804e7b9
24 changed files with 5485 additions and 184 deletions
|
|
@ -10,6 +10,8 @@ export const Permission = {
|
|||
INCREMENT_COUNTER: "increment_counter",
|
||||
USE_SUM: "use_sum",
|
||||
VIEW_AUDIT: "view_audit",
|
||||
MANAGE_INVITES: "manage_invites",
|
||||
VIEW_OWN_INVITES: "view_own_invites",
|
||||
} as const;
|
||||
|
||||
export type PermissionType = typeof Permission[keyof typeof Permission];
|
||||
|
|
@ -25,7 +27,7 @@ interface AuthContextType {
|
|||
user: User | null;
|
||||
isLoading: boolean;
|
||||
login: (email: string, password: string) => Promise<void>;
|
||||
register: (email: string, password: string) => Promise<void>;
|
||||
register: (email: string, password: string, inviteIdentifier: string) => Promise<void>;
|
||||
logout: () => Promise<void>;
|
||||
hasPermission: (permission: PermissionType) => boolean;
|
||||
hasRole: (role: string) => boolean;
|
||||
|
|
@ -65,9 +67,13 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
|||
}
|
||||
};
|
||||
|
||||
const register = async (email: string, password: string) => {
|
||||
const register = async (email: string, password: string, inviteIdentifier: string) => {
|
||||
try {
|
||||
const userData = await api.post<User>("/api/auth/register", { email, password });
|
||||
const userData = await api.post<User>("/api/auth/register", {
|
||||
email,
|
||||
password,
|
||||
invite_identifier: inviteIdentifier,
|
||||
});
|
||||
setUser(userData);
|
||||
} catch (err) {
|
||||
if (err instanceof ApiError) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue