mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
fix: passenger id
This commit is contained in:
@@ -180,6 +180,9 @@ export class PassengerAuthService {
|
||||
|
||||
return {
|
||||
iamUserId,
|
||||
// Top-level passengerId keeps the profile shape consistent with the login
|
||||
// response so the web User object always carries it (the JWT does not).
|
||||
passengerId: passenger.id,
|
||||
email: iam?.email ?? null,
|
||||
phone: iam?.phone_number ?? null,
|
||||
fullName: iam?.name?.en ?? iam?.name?.am ?? null,
|
||||
|
||||
@@ -260,11 +260,23 @@ export default function ReviewPage() {
|
||||
if (localStoragePassengerId) passengerId = localStoragePassengerId;
|
||||
}
|
||||
|
||||
// Fallback 3: Use passengerId from user object
|
||||
// Fallback 3: Use passengerId from user object. The profile response nests
|
||||
// it under `passenger.id`, while the login response exposes it top-level as
|
||||
// `passengerId` — accept either shape so a cached profile user still resolves.
|
||||
if (!passengerId && user) {
|
||||
passengerId = (user as any).passengerId;
|
||||
passengerId = (user as any).passengerId || (user as any).passenger?.id;
|
||||
}
|
||||
|
||||
|
||||
// Fallback 4: last resort — fetch the passenger profile directly.
|
||||
if (!passengerId) {
|
||||
try {
|
||||
const me: any = await apiClient.get('/passengers/me');
|
||||
passengerId = me?.id || me?.passengerId || '';
|
||||
} catch (err) {
|
||||
console.error('Failed to resolve passengerId from /passengers/me:', err);
|
||||
}
|
||||
}
|
||||
|
||||
if (!passengerId) {
|
||||
throw new Error('Passenger ID not found in authentication token. Please log in again.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user