74 lines
2.4 KiB
PHP
74 lines
2.4 KiB
PHP
<?php
|
|
// header('Content-Type: application/json');
|
|
|
|
// require_once './descope_config.php'; // Descope API 키 등 공통설정
|
|
|
|
// $email = trim($_POST['email'] ?? '');
|
|
|
|
// if (!$email) {
|
|
// echo json_encode(['status' => 'fail', 'message' => '이메일 없음']);
|
|
// exit;
|
|
// }
|
|
|
|
// // Descope OTP 메일 전송 (예: signup/send/otp)
|
|
// $url = 'https://api.descope.com/v1/auth/magiclink/email/send'; // API 버전에 맞게!
|
|
// $data = [
|
|
// "loginId" => $email,
|
|
// "user" => ["email" => $email]
|
|
// ];
|
|
|
|
// $ch = curl_init($url);
|
|
// curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
|
// "Authorization: Bearer " . $DESCOPE_API_KEY,
|
|
// "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 {
|
|
// echo json_encode(['status' => 'fail', 'message' => 'OTP 발송 실패', 'raw' => $response]);
|
|
// }
|
|
?>
|
|
|
|
<?php
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
$email = $_POST['email'] ?? '';
|
|
// $email = 'sdi9429@naver.com';
|
|
// $redirectUrl = 'https://eg-bim.com/eng/index.php?popup=pwreset';
|
|
if (!$email) exit(json_encode(['status'=>'fail', 'message'=>'이메일 누락']));
|
|
$api_key = "P2wON5fy1K6kyia269VpeIzYP8oP";
|
|
$url = "https://api.descope.com/v1/auth/password/reset";
|
|
$data = [
|
|
"loginId" => $email,
|
|
"redirectUrl" => 'https://eg-bim.co.kr/eng/index.php?popup=pwreset'
|
|
];
|
|
$ch = curl_init($url);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
|
"Authorization: Bearer {$api_key}",
|
|
"Content-Type: application/json"
|
|
]);
|
|
curl_setopt($ch, CURLOPT_POST, true);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
$res = curl_exec($ch);
|
|
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
curl_close($ch);
|
|
if ($http_code == 200) {
|
|
$res_data = json_decode($res, true); // 응답 파싱
|
|
$linkId = $res_data['linkId'] ?? '';
|
|
echo json_encode([
|
|
'status'=>'ok',
|
|
'linkId'=>$linkId,
|
|
'raw_response'=>$res_data // (디버깅용 전체도 같이 보고 싶으면)
|
|
]);
|
|
} else {
|
|
echo json_encode(['status'=>'fail','message'=>'Failed to send.']);
|
|
}
|
|
?>
|