Wrapped additional error data under data
This commit is contained in:
@ -45,9 +45,9 @@ class AuthStore {
|
||||
this.team = res.data.team;
|
||||
});
|
||||
} catch (err) {
|
||||
if (err.data.error === 'user_suspended') {
|
||||
if (err.error.error === 'user_suspended') {
|
||||
this.isSuspended = true;
|
||||
this.suspendedContactEmail = err.data.adminEmail;
|
||||
this.suspendedContactEmail = err.error.data.adminEmail;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -84,7 +84,7 @@ class ApiClient {
|
||||
})
|
||||
.catch(error => {
|
||||
error.response.json().then(json => {
|
||||
error.data = json;
|
||||
error.error = json;
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
|
@ -55,7 +55,7 @@ api.use(async (ctx, next) => {
|
||||
error: _.snakeCase(err.id || error),
|
||||
status: err.status,
|
||||
message,
|
||||
adminEmail: err.adminEmail ? err.adminEmail : undefined,
|
||||
data: err.errorData ? err.errorData : undefined,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
@ -181,7 +181,7 @@ describe('Authentication middleware', async () => {
|
||||
expect(e.message).toEqual(
|
||||
'Your access has been suspended by the team admin'
|
||||
);
|
||||
expect(e.adminEmail).toEqual(admin.email);
|
||||
expect(e.errorData.adminEmail).toEqual(admin.email);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -22,7 +22,9 @@ export function AdminRequiredError(
|
||||
export function UserSuspendedError({ adminEmail }: { adminEmail: string }) {
|
||||
return httpErrors(403, 'Your access has been suspended by the team admin', {
|
||||
id: 'user_suspended',
|
||||
adminEmail,
|
||||
errorData: {
|
||||
adminEmail,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user