Harden auth cookies and fix native schema for event creation
Mirror to GitHub / mirror (push) Successful in 45s
Test and Lint / backend-test (push) Successful in 1m37s
Test and Lint / frontend-test (push) Successful in 2m8s
Version and Release / version-bump (push) Successful in 1m0s
Version and Release / trigger-drone (push) Successful in 3s
Mirror to GitHub / mirror (push) Successful in 45s
Test and Lint / backend-test (push) Successful in 1m37s
Test and Lint / frontend-test (push) Successful in 2m8s
Version and Release / version-bump (push) Successful in 1m0s
Version and Release / trigger-drone (push) Successful in 3s
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { api, setAuthToken, clearAuthToken } from '../config/api';
|
||||
import { api } from '../config/api';
|
||||
import type { LoginResponse, GalleryAuthResponse } from '../types';
|
||||
|
||||
export const authService = {
|
||||
@@ -10,14 +10,17 @@ export const authService = {
|
||||
password: credentials.password,
|
||||
recaptchaToken: credentials.recaptchaToken
|
||||
});
|
||||
|
||||
setAuthToken(response.data.token, true);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
adminLogout() {
|
||||
clearAuthToken(true);
|
||||
window.location.href = '/admin/login';
|
||||
async adminLogout() {
|
||||
try {
|
||||
await api.post('/auth/logout');
|
||||
} catch (err) {
|
||||
// Ignore logout errors; fallback to redirect
|
||||
} finally {
|
||||
window.location.href = '/admin/login';
|
||||
}
|
||||
},
|
||||
|
||||
// Gallery authentication
|
||||
@@ -32,7 +35,19 @@ export const authService = {
|
||||
return response.data;
|
||||
},
|
||||
|
||||
galleryLogout() {
|
||||
// Logout is now handled by GalleryAuthContext
|
||||
async shareLinkLogin(slug: string, token: string): Promise<GalleryAuthResponse> {
|
||||
const response = await api.post<GalleryAuthResponse>('/auth/gallery/share-login', {
|
||||
slug,
|
||||
token,
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
|
||||
async galleryLogout(slug?: string | null) {
|
||||
try {
|
||||
await api.post('/auth/gallery/logout', { slug });
|
||||
} catch (err) {
|
||||
// Ignore; cookie will naturally expire if removal fails
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -49,21 +49,10 @@ class SecureTokenService {
|
||||
}
|
||||
|
||||
try {
|
||||
// Get the gallery token from localStorage
|
||||
const galleryToken = localStorage.getItem(`gallery_token_${slug}`);
|
||||
if (!galleryToken) {
|
||||
throw new Error('No gallery authentication token found');
|
||||
}
|
||||
|
||||
// Generate new token from backend with explicit auth header
|
||||
// Generate new token from backend – authentication handled via cookies
|
||||
const response = await api.post<SecureToken>(
|
||||
`/secure-images/${slug}/generate-token`,
|
||||
{ photoId, accessType },
|
||||
{
|
||||
headers: {
|
||||
'Authorization': `Bearer ${galleryToken}`
|
||||
}
|
||||
}
|
||||
{ photoId, accessType }
|
||||
);
|
||||
|
||||
const tokenData: SecureToken = {
|
||||
@@ -190,4 +179,4 @@ if (typeof window !== 'undefined') {
|
||||
setInterval(() => {
|
||||
secureTokenService.clearExpiredTokens();
|
||||
}, 5 * 60 * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user