DELETE /auth/delete-account threw "User not found" for every OAuth-only account (any user with no password always failed `!user.password`), and both the web and mobile clients called /v1/compliance/account and /compliance/account, routes that never existed - so account deletion was broken for 100% of users on every surface, not just OAuth. Password accounts still require re-entering their password; OAuth-only accounts delete using the authenticated session as proof instead. Web and mobile now check whether the account has a password before showing the field, and call the real /auth/delete-account route. Backend keeps a DELETE /auth/account alias for any already-shipped client builds. 70/70 backend auth tests pass, including 3 new cases for the OAuth-without-password path and the password-missing/wrong-password cases.
29 lines
801 B
TypeScript
29 lines
801 B
TypeScript
import api from './api';
|
|
|
|
export const complianceService = {
|
|
exportUserData: async () => {
|
|
const response = await api.get('/compliance/export-data');
|
|
return response.data;
|
|
},
|
|
|
|
/**
|
|
* Deletes the account. The backend lives at `DELETE /auth/delete-account`
|
|
* (not `/compliance/account`, which never existed and always 404'd).
|
|
* Password accounts must pass `password`; OAuth-only accounts omit it.
|
|
*/
|
|
deleteAccount: async (password?: string) => {
|
|
const response = await api.delete('/auth/delete-account', {
|
|
data: password ? { password } : {},
|
|
});
|
|
return response.data;
|
|
},
|
|
|
|
updateDataRetention: async (retentionDays: number) => {
|
|
const response = await api.put('/compliance/retention', {
|
|
retentionDays,
|
|
});
|
|
return response.data;
|
|
},
|
|
};
|
|
|