mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 20:21:09 +02:00
🩹 fix(bot-services): export LOGIN_MESSAGES and auth error helpers
Export the following from @manacore/bot-services: - LOGIN_MESSAGES: Pre-defined auth error messages for all bot types - AUTH_ERROR_MESSAGES: Same as LOGIN_MESSAGES (preferred name) - formatAuthErrorMessage(): Helper to create custom auth error messages These are used by bots to show consistent error messages when token refresh fails and the user needs to re-authenticate. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
ff1affb268
commit
4a26926fae
5 changed files with 244 additions and 12 deletions
|
|
@ -100,6 +100,11 @@ export {
|
|||
REDIS_CLIENT,
|
||||
SESSION_MODULE_OPTIONS,
|
||||
DEFAULT_SESSION_EXPIRY_MS,
|
||||
formatAuthErrorMessage,
|
||||
AUTH_ERROR_MESSAGES,
|
||||
// Deprecated - kept for backwards compatibility
|
||||
formatLoginRequiredMessage,
|
||||
LOGIN_MESSAGES,
|
||||
} from './session/index.js';
|
||||
export type {
|
||||
UserSession,
|
||||
|
|
|
|||
|
|
@ -8,4 +8,12 @@ export type {
|
|||
SessionModuleOptions,
|
||||
SessionStorageMode,
|
||||
} from './types';
|
||||
export { SESSION_MODULE_OPTIONS, DEFAULT_SESSION_EXPIRY_MS } from './types';
|
||||
export {
|
||||
SESSION_MODULE_OPTIONS,
|
||||
DEFAULT_SESSION_EXPIRY_MS,
|
||||
formatAuthErrorMessage,
|
||||
AUTH_ERROR_MESSAGES,
|
||||
// Deprecated - kept for backwards compatibility
|
||||
formatLoginRequiredMessage,
|
||||
LOGIN_MESSAGES,
|
||||
} from './types';
|
||||
|
|
|
|||
|
|
@ -78,3 +78,48 @@ export const SESSION_MODULE_OPTIONS = 'SESSION_MODULE_OPTIONS';
|
|||
* Default session expiry: 7 days in milliseconds
|
||||
*/
|
||||
export const DEFAULT_SESSION_EXPIRY_MS = 7 * 24 * 60 * 60 * 1000;
|
||||
|
||||
/**
|
||||
* Standard auth error message for all bots
|
||||
* Used when SSO-Link fails to authenticate the user automatically.
|
||||
* Since all users authenticate via OIDC, this indicates a technical issue.
|
||||
*/
|
||||
export function formatAuthErrorMessage(featureDescription: string): string {
|
||||
return (
|
||||
'⚠️ **Authentifizierung fehlgeschlagen**\n\n' +
|
||||
`Um ${featureDescription} zu nutzen, muss dein Account verknüpft sein.\n\n` +
|
||||
'Bitte logge dich in Element neu ein über "Mit Mana Core anmelden".\n\n' +
|
||||
'Falls das Problem weiterhin besteht, kontaktiere den Support.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-defined auth error messages for all bot types
|
||||
*/
|
||||
export const AUTH_ERROR_MESSAGES = {
|
||||
clock: formatAuthErrorMessage('Timer und Alarme'),
|
||||
todo: formatAuthErrorMessage('Aufgaben'),
|
||||
calendar: formatAuthErrorMessage('Termine'),
|
||||
contacts: formatAuthErrorMessage('Kontakte'),
|
||||
picture: formatAuthErrorMessage('Bilder'),
|
||||
zitare: formatAuthErrorMessage('Favoriten'),
|
||||
nutriphi: formatAuthErrorMessage('Mahlzeiten'),
|
||||
chat: formatAuthErrorMessage('Chats'),
|
||||
storage: formatAuthErrorMessage('Dateien'),
|
||||
skilltree: formatAuthErrorMessage('Skills'),
|
||||
presi: formatAuthErrorMessage('Präsentationen'),
|
||||
planta: formatAuthErrorMessage('Pflanzen'),
|
||||
manadeck: formatAuthErrorMessage('Decks'),
|
||||
questions: formatAuthErrorMessage('Fragen'),
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* @deprecated Use formatAuthErrorMessage instead. Kept for backwards compatibility.
|
||||
*/
|
||||
export const formatLoginRequiredMessage = (featureDescription: string, _appName: string): string =>
|
||||
formatAuthErrorMessage(featureDescription);
|
||||
|
||||
/**
|
||||
* @deprecated Use AUTH_ERROR_MESSAGES instead. Kept for backwards compatibility.
|
||||
*/
|
||||
export const LOGIN_MESSAGES = AUTH_ERROR_MESSAGES;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue