Build post chat and attachment workflows
All checks were successful
CI / backend (push) Successful in 13m8s
CI / frontend (push) Successful in 10m46s
CI / docker (push) Successful in 2m59s

This commit is contained in:
Cauê Faleiros
2026-06-08 16:44:33 -03:00
parent 8c7e5fbbe4
commit 0b920da187
30 changed files with 3021 additions and 204 deletions

View File

@@ -16,20 +16,35 @@ type LoginResponse = {
user: AuthUser;
};
type AcceptInvitationResponse = {
message: string;
user: AuthUser;
};
type MeResponse = {
user: AuthUser;
};
export function getStoredToken() {
return localStorage.getItem(TOKEN_STORAGE_KEY);
return sessionStorage.getItem(TOKEN_STORAGE_KEY);
}
export function storeToken(token: string) {
localStorage.setItem(TOKEN_STORAGE_KEY, token);
localStorage.removeItem(TOKEN_STORAGE_KEY);
sessionStorage.setItem(TOKEN_STORAGE_KEY, token);
}
export function clearStoredToken() {
localStorage.removeItem(TOKEN_STORAGE_KEY);
sessionStorage.removeItem(TOKEN_STORAGE_KEY);
}
export async function logout() {
await apiRequest<{ message: string }>("/auth/logout", {
method: "POST",
}).catch(() => undefined);
localStorage.removeItem(TOKEN_STORAGE_KEY);
sessionStorage.removeItem(TOKEN_STORAGE_KEY);
}
export async function login(email: string, password: string) {
@@ -43,11 +58,19 @@ export async function login(email: string, password: string) {
}
export async function acceptInvitation(token: string, name: string, password: string) {
const response = await apiRequest<LoginResponse>("/auth/invitations/accept", {
const response = await apiRequest<AcceptInvitationResponse>("/auth/invitations/accept", {
method: "POST",
body: JSON.stringify({ token, name, password }),
});
return response;
}
export async function refreshSession() {
const response = await apiRequest<LoginResponse>("/auth/refresh", {
method: "POST",
});
storeToken(response.access_token);
return response;
}