최초 커밋
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
// ini_set('display_errors', 1);
|
||||
// ini_set('display_startup_errors', 1);
|
||||
// error_reporting(E_ALL);
|
||||
|
||||
// header('Content-Type: application/json');
|
||||
// // require_once './descope_config.php';
|
||||
|
||||
// $email = trim($_POST['email'] ?? '');
|
||||
// $password = trim($_POST['password'] ?? '');
|
||||
// $refreshJwt = trim($_POST['refreshJwt'] ?? '');
|
||||
|
||||
// if (!$email || !$password || !$refreshJwt) {
|
||||
// echo json_encode(['status' => 'fail', 'message' => '필수값 없음']);
|
||||
// exit;
|
||||
// }
|
||||
|
||||
// // Descope API - 비밀번호 변경 엔드포인트 사용
|
||||
// $url = "https://api.descope.com/v1/auth/password/update";
|
||||
// $data = [
|
||||
// // "loginId" => $email,
|
||||
// "newPassword" => $password,
|
||||
// ];
|
||||
|
||||
// $ch = curl_init($url);
|
||||
// curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
// "Authorization: Bearer " . $refreshJwt,
|
||||
// "Content-Type: application/json"
|
||||
// ]);
|
||||
// curl_setopt($ch, CURLOPT_POST, 1);
|
||||
// curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
||||
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
||||
// $response = curl_exec($ch);
|
||||
// $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
// curl_close($ch);
|
||||
|
||||
// if ($code == 200) {
|
||||
// echo json_encode(['status' => 'ok']);
|
||||
// } else {
|
||||
// $resData = json_decode($response, true);
|
||||
// $msg = $resData['errorDescription'] ?? '비밀번호 변경 실패';
|
||||
// echo json_encode(['status' => 'fail', 'message' => $msg, 'raw' => $response]);
|
||||
// }
|
||||
|
||||
// ini_set('display_errors', 1);
|
||||
// ini_set('display_startup_errors', 1);
|
||||
// error_reporting(E_ALL);
|
||||
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
header('Content-Type: application/json');
|
||||
// require_once './descope_config.php';
|
||||
|
||||
$projectId = 'P2wON5fy1K6kyia269VpeIzYP8oP';
|
||||
$email = trim($_POST['email'] ?? '');
|
||||
$password = trim($_POST['password'] ?? '');
|
||||
$refreshJwt = trim($_POST['refreshJwt'] ?? '');
|
||||
|
||||
// if (!$email || !$password || !$refreshJwt) {
|
||||
// echo json_encode(['status' => 'fail', 'message' => '필수값 없음']);
|
||||
// exit;
|
||||
// }
|
||||
|
||||
if (!$email || !$password || !$refreshJwt) {
|
||||
echo json_encode([
|
||||
'status' => 'fail',
|
||||
'message' => '필수값 없음',
|
||||
'debug' => [
|
||||
'email' => $email,
|
||||
'password' => $password,
|
||||
'refreshJwt' => $refreshJwt // <<< 확인!
|
||||
]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Descope API - 비밀번호 변경 엔드포인트 사용
|
||||
$url = "https://api.descope.com/v1/auth/password/update";
|
||||
$data = [
|
||||
"loginId" => $email,
|
||||
"newPassword" => $password,
|
||||
];
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Authorization: Bearer {$projectId}:{$refreshJwt}",
|
||||
"Content-Type: application/json",
|
||||
// "x-descope-project-id: $projectId"
|
||||
]);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
if ($code == 200) {
|
||||
echo json_encode(['status' => 'ok']);
|
||||
} else {
|
||||
$resData = json_decode($response, true);
|
||||
$msg = $resData['errorDescription'] ?? '비밀번호 변경 실패';
|
||||
echo json_encode(['status' => 'fail', 'message' => $msg, 'raw' => $response]);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user