Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 250f5bd62e | |||
| c484ac5567 | |||
| e2b20fef2e | |||
| 03cead6102 | |||
| 5ac6f16fb5 | |||
| 681efc4383 | |||
| 8740f35728 |
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
@@ -1,4 +1,4 @@
|
||||
import PocketBase from 'pocketbase';
|
||||
import PocketBase, { BaseAuthStore } from 'pocketbase';
|
||||
|
||||
// Dynamically detect API base URL from current host (for use in browser)
|
||||
const dynamicBaseUrl =
|
||||
@@ -28,8 +28,9 @@ export const setApiEndpoint = (endpoint: string): void => {
|
||||
}
|
||||
};
|
||||
|
||||
// Initialize the PocketBase client with the current API URL
|
||||
export const pb = new PocketBase(getCurrentEndpoint());
|
||||
// Initialize the PocketBase client with an in-memory auth store so auth tokens
|
||||
// are not persisted in localStorage where XSS can trivially exfiltrate them.
|
||||
export const pb = new PocketBase(getCurrentEndpoint(), new BaseAuthStore());
|
||||
|
||||
// Helper to check if user is authenticated
|
||||
export const isAuthenticated = () => {
|
||||
@@ -39,28 +40,7 @@ export const isAuthenticated = () => {
|
||||
// Export the auth store for use in components
|
||||
export const authStore = pb.authStore;
|
||||
|
||||
// Configure PocketBase to persist authentication between page reloads
|
||||
// Remove any auth tokens that may have been persisted by earlier versions.
|
||||
if (typeof window !== 'undefined') {
|
||||
const storedAuthData = localStorage.getItem('pocketbase_auth');
|
||||
if (storedAuthData) {
|
||||
try {
|
||||
const parsedData = JSON.parse(storedAuthData);
|
||||
pb.authStore.save(parsedData.token, parsedData.model);
|
||||
} catch (error) {
|
||||
console.error('Failed to parse stored auth data:', error);
|
||||
localStorage.removeItem('pocketbase_auth');
|
||||
}
|
||||
}
|
||||
|
||||
// Subscribe to authStore changes to persist authentication
|
||||
pb.authStore.onChange(() => {
|
||||
if (pb.authStore.isValid) {
|
||||
localStorage.setItem('pocketbase_auth', JSON.stringify({
|
||||
token: pb.authStore.token,
|
||||
model: pb.authStore.model
|
||||
}));
|
||||
} else {
|
||||
localStorage.removeItem('pocketbase_auth');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
import { MaintenanceTranslations } from '../types/maintenance';
|
||||
|
||||
export const maintenanceTranslations: MaintenanceTranslations = {
|
||||
@@ -77,4 +78,12 @@ export const maintenanceTranslations: MaintenanceTranslations = {
|
||||
selectNotificationChannel: 'Benachrichtigungskanal hinzufügen',
|
||||
enableNotificationsFirst: 'Aktivieren Sie zuerst Benachrichtigungen, um einen Kanal auszuwählen',
|
||||
updateMaintenance: 'Wartung aktualisieren',
|
||||
loginToViewProfile: 'Bitte melden Sie sich an, um Ihr Profil anzuzeigen',
|
||||
goToLogin: 'Zum Login',
|
||||
loadingUserData: 'Benutzerdaten werden geladen...',
|
||||
retry: 'Erneut versuchen',
|
||||
loadingServerData: 'Serverdaten werden geladen...',
|
||||
retrievingYourInformation: 'Bitte warten Sie, während wir Ihre Informationen abrufen...',
|
||||
servicesPagination: '{startItem}-{endItem} von {totalItems} Diensten',
|
||||
servicesPaginationNoService: '0 Dienste',
|
||||
};
|
||||
|
||||
@@ -64,4 +64,25 @@ export const maintenanceTranslations: MaintenanceTranslations = {
|
||||
noScheduledMaintenance: 'スケジュール済みメンテナンスなし',
|
||||
noMaintenanceWindows: 'この期間にメンテナンスウィンドウはありません。「メンテナンス作成」ボタンをクリックして作成してください。',
|
||||
maintenanceCreatedSuccess: 'メンテナンスウィンドウが正常に作成されました',
|
||||
assignedPersonnelDescription: '現在割り当てられているユーザー',
|
||||
editMaintenanceDesc: 'メンテナンス詳細を編集',
|
||||
editMaintenanceWindow: 'メンテナンス編集',
|
||||
enableNotificationsFirst: 'チャンネルを選択するには先に通知を有効にしてください',
|
||||
goToLogin: 'ログインへ',
|
||||
impactLevel: '影響レベル',
|
||||
impactLevelDescription: '影響レベルを選択',
|
||||
loadingServerData: 'サーバーデータを読み込み中...',
|
||||
loadingUserData: 'ユーザーデータを読み込み中...',
|
||||
loginToViewProfile: 'プロフィールを表示するにはログインしてください',
|
||||
mutedNotifications: '通知が無効になっています',
|
||||
notificationsAreMuted: 'このメンテナンスでは現在通知がミュートされています',
|
||||
priorityDescription: 'メンテナンス優先度を選択',
|
||||
retrievingYourInformation: '情報を取得しています。しばらくお待ちください...',
|
||||
retry: '再試行',
|
||||
selectAssignedUsers: '割り当てユーザーを選択',
|
||||
selectNotificationChannel: '通知チャンネルを追加',
|
||||
servicesPagination: '{startItem}-{endItem} / {totalItems} サービス',
|
||||
servicesPaginationNoService: '0 サービス',
|
||||
statusDescription: 'メンテナンスステータスを選択',
|
||||
updateMaintenance: 'メンテナンスを更新',
|
||||
};
|
||||
@@ -78,4 +78,12 @@ export const maintenanceTranslations: MaintenanceTranslations = {
|
||||
selectNotificationChannel: '알림 채널 추가',
|
||||
enableNotificationsFirst: '채널을 선택하려면 먼저 알림을 활성화하세요',
|
||||
updateMaintenance: '유지보수 업데이트',
|
||||
goToLogin: '로그인으로 이동',
|
||||
loadingServerData: '서버 데이터를 불러오는 중...',
|
||||
loadingUserData: '사용자 데이터를 불러오는 중...',
|
||||
loginToViewProfile: '프로필을 보려면 로그인하세요',
|
||||
retrievingYourInformation: '정보를 가져오는 중입니다. 잠시 기다려 주세요...',
|
||||
retry: '다시 시도',
|
||||
servicesPagination: '{startItem}-{endItem} / {totalItems} 서비스',
|
||||
servicesPaginationNoService: '0 서비스',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user