45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?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]);
|
|
}
|
|
?>
|