@micha.bigler/ui-core-micha 1.3.4 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/authApi.js +11 -10
- package/package.json +1 -1
- package/src/auth/authApi.jsx +12 -9
package/dist/auth/authApi.js
CHANGED
|
@@ -373,32 +373,33 @@ export async function authenticateWithMFA({ code, credential }) {
|
|
|
373
373
|
// Authentication: password (MODIFIZIERT)
|
|
374
374
|
// -----------------------------
|
|
375
375
|
export async function loginWithPassword(email, password) {
|
|
376
|
-
var _a, _b;
|
|
376
|
+
var _a, _b, _c;
|
|
377
377
|
try {
|
|
378
378
|
await axios.post(`${HEADLESS_BASE}/auth/login`, { email, password }, { withCredentials: true });
|
|
379
379
|
}
|
|
380
380
|
catch (error) {
|
|
381
381
|
const status = (_a = error.response) === null || _a === void 0 ? void 0 : _a.status;
|
|
382
382
|
const data = (_b = error.response) === null || _b === void 0 ? void 0 : _b.data;
|
|
383
|
-
|
|
384
|
-
//
|
|
385
|
-
//
|
|
386
|
-
|
|
383
|
+
console.log('Login Error Debug:', { status, data });
|
|
384
|
+
// --- SKEPTISCHER CHECK (KORRIGIERT) ---
|
|
385
|
+
// Wir suchen in der Liste 'flows' nach einem Eintrag mit id='mfa_authenticate'
|
|
386
|
+
// und prüfen, ob er 'is_pending' ist.
|
|
387
|
+
const mfaFlow = (_c = data === null || data === void 0 ? void 0 : data.flows) === null || _c === void 0 ? void 0 : _c.find(f => f.id === 'mfa_authenticate');
|
|
388
|
+
if (status === 401 && mfaFlow && mfaFlow.is_pending) {
|
|
387
389
|
return {
|
|
388
390
|
needsMfa: true,
|
|
389
|
-
availableTypes:
|
|
391
|
+
availableTypes: mfaFlow.types || [], // ["recovery_codes", "webauthn"]
|
|
390
392
|
};
|
|
391
393
|
}
|
|
392
|
-
// ---
|
|
394
|
+
// --- Already Logged In ---
|
|
393
395
|
if (status === 409) {
|
|
394
|
-
//
|
|
396
|
+
// user ist schon eingeloggt
|
|
395
397
|
}
|
|
396
398
|
else {
|
|
397
|
-
// Echter Fehler (z.B. falsches Passwort oder Serverfehler)
|
|
398
399
|
throw new Error(extractErrorMessage(error));
|
|
399
400
|
}
|
|
400
401
|
}
|
|
401
|
-
//
|
|
402
|
+
// Erfolg ohne MFA
|
|
402
403
|
const user = await fetchCurrentUser();
|
|
403
404
|
return { user, needsMfa: false };
|
|
404
405
|
}
|
package/package.json
CHANGED
package/src/auth/authApi.jsx
CHANGED
|
@@ -495,26 +495,29 @@ export async function loginWithPassword(email, password) {
|
|
|
495
495
|
const status = error.response?.status;
|
|
496
496
|
const data = error.response?.data;
|
|
497
497
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
//
|
|
501
|
-
|
|
498
|
+
console.log('Login Error Debug:', { status, data });
|
|
499
|
+
|
|
500
|
+
// --- SKEPTISCHER CHECK (KORRIGIERT) ---
|
|
501
|
+
// Wir suchen in der Liste 'flows' nach einem Eintrag mit id='mfa_authenticate'
|
|
502
|
+
// und prüfen, ob er 'is_pending' ist.
|
|
503
|
+
const mfaFlow = data?.flows?.find(f => f.id === 'mfa_authenticate');
|
|
504
|
+
|
|
505
|
+
if (status === 401 && mfaFlow && mfaFlow.is_pending) {
|
|
502
506
|
return {
|
|
503
507
|
needsMfa: true,
|
|
504
|
-
availableTypes:
|
|
508
|
+
availableTypes: mfaFlow.types || [], // ["recovery_codes", "webauthn"]
|
|
505
509
|
};
|
|
506
510
|
}
|
|
507
511
|
|
|
508
|
-
// ---
|
|
512
|
+
// --- Already Logged In ---
|
|
509
513
|
if (status === 409) {
|
|
510
|
-
|
|
514
|
+
// user ist schon eingeloggt
|
|
511
515
|
} else {
|
|
512
|
-
// Echter Fehler (z.B. falsches Passwort oder Serverfehler)
|
|
513
516
|
throw new Error(extractErrorMessage(error));
|
|
514
517
|
}
|
|
515
518
|
}
|
|
516
519
|
|
|
517
|
-
//
|
|
520
|
+
// Erfolg ohne MFA
|
|
518
521
|
const user = await fetchCurrentUser();
|
|
519
522
|
return { user, needsMfa: false };
|
|
520
523
|
}
|