merge dev branch
This commit is contained in:
commit
58fbacaa52
25 changed files with 765 additions and 104 deletions
35
public/site/config/routes/login.php
Normal file
35
public/site/config/routes/login.php
Normal 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>"
|
||||
]);
|
||||
}
|
||||
},
|
||||
];
|
||||
|
|
@ -10,6 +10,6 @@ return [
|
|||
session_start();
|
||||
}
|
||||
|
||||
go(site()->panel()->url());
|
||||
go(site()->url() . '/login');
|
||||
},
|
||||
];
|
||||
|
|
|
|||
22
public/site/config/routes/update-email.php
Normal file
22
public/site/config/routes/update-email.php
Normal 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()
|
||||
];
|
||||
}
|
||||
}
|
||||
];
|
||||
22
public/site/config/routes/update-password.php
Normal file
22
public/site/config/routes/update-password.php
Normal 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()
|
||||
];
|
||||
}
|
||||
}
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue