designtopack/public/site/config/routes/update-email.php
2025-05-05 17:30:17 +02:00

22 lines
No EOL
534 B
PHP

<?php
return [
'pattern' => '/update-email.json',
'method' => 'POST',
'action' => function() {
$json = file_get_contents("php://input");
$data = json_decode($json);
try {
kirby()->user()->changeEmail($data->email);
return [
'status' => 'success'
];
} catch (\Throwable $th) {
return [
'status' => 'error',
'message' => 'Impossible de mettre à jour l\'email : ' . $th->getMessage() . ' in file ' . $th->getFile() . ' line ' . $th->getLine()
];
}
}
];