feat: implement email change request functionality with verification dialog

This commit is contained in:
pradeepkumar
2026-04-20 14:07:37 +05:30
parent 6b0fa24b85
commit 3c61c25f5e
2 changed files with 158 additions and 5 deletions

View File

@@ -207,6 +207,28 @@ class ProfileRepository {
}
}
/// Request email change: POST /auth/change-email
/// Backend sends a verification link to [newEmail]; email is only
/// persisted once the link is clicked.
Future<String> requestEmailChange(String newEmail, String password) async {
try {
final response = await _dio.post('/auth/change-email', data: {
'newEmail': newEmail,
'password': password,
});
return (response.data?['data']?['message'] as String?) ??
'Verification link sent';
} on DioException catch (e) {
if (e.error is ApiException) throw e.error as ApiException;
throw ApiException(
message: e.response?.data?['message'] ??
e.message ??
'Failed to request email change',
statusCode: e.response?.statusCode,
);
}
}
/// Fetch notification preferences.
/// Agent: GET /agents/preferences/notifications
/// User: GET /users/preferences/notifications