feat: implement email change request functionality with verification dialog
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user