Game-Jaming/Backend/Controllers/Group/ResetPassword.php

30 lines
833 B
PHP
Raw Normal View History

2021-03-08 12:01:01 +00:00
<?php
require_once "../../../bootstrap.php";
2021-03-11 10:13:06 +00:00
require_once "../Admin/Admin.php";
2021-03-08 12:01:01 +00:00
2021-03-12 13:05:31 +00:00
use \Backend\Models\Password;
2021-03-08 12:01:01 +00:00
2021-03-12 10:10:14 +00:00
//session_start();
2021-04-19 07:15:15 +00:00
if (isAdmin()) {
if (isset($_POST['restPassword'])) {
$password = Password::firstWhere("group_id", $_POST['groupId']);
if ($password) {
$password->password = password_hash($_POST['newPassword'], PASSWORD_DEFAULT);
2021-03-12 13:05:31 +00:00
echo $password;
2021-04-19 07:15:15 +00:00
if (!$password->save()) {
2021-03-23 12:39:44 +00:00
http_response_code(500);
2021-04-19 07:15:15 +00:00
} else {
2021-03-23 12:39:44 +00:00
http_response_code(201);
2021-03-09 09:45:05 +00:00
}
2021-04-19 07:15:15 +00:00
} else {
2021-03-23 12:39:44 +00:00
http_response_code(400);
echo json_encode(["message" => "group not found"]);
2021-03-08 12:01:01 +00:00
}
2021-03-12 13:05:31 +00:00
2021-04-19 07:15:15 +00:00
} else {
2021-03-23 12:39:44 +00:00
http_response_code(400);
2021-03-08 12:01:01 +00:00
}
2021-04-19 07:15:15 +00:00
} else {
2021-03-23 12:39:44 +00:00
http_response_code(401);
echo json_encode(["message" => "is not admin"]);
2021-03-08 12:01:01 +00:00
}