merge dev branch

This commit is contained in:
isUnknown 2025-09-09 17:28:45 +02:00
commit 58fbacaa52
25 changed files with 765 additions and 104 deletions

View file

@ -0,0 +1,35 @@
<?php
return [
"pattern" => "login.json",
"method" => "POST",
"action" => function () {
$json = file_get_contents("php://input");
$data = json_decode($json);
$kirby = kirby();
$email = $data->email;
$password = $data->password;
if(V::email($email)) {
try {
$kirby->auth()->login($email, $password, true);
return json_encode([
"status" => "success",
"role" => (string) $kirby->user()->role()
]);
} catch (Exception $e) {
return json_encode([
"status" => "error",
"message" => "<strong>Email ou mot de passe invalide.</strong><br>Contactez l'administrateur pour demander la réinitialisation de vos informations de connexion."
]);
}
} else {
return json_encode([
"status" => "error",
"message" => "<strong>Email invalide.</strong>"
]);
}
},
];

View file

@ -10,6 +10,6 @@ return [
session_start();
}
go(site()->panel()->url());
go(site()->url() . '/login');
},
];

View file

@ -0,0 +1,22 @@
<?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()
];
}
}
];

View file

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