18 lines
836 B
PHP
18 lines
836 B
PHP
<?php
|
|
header("Content-Type: application/json");
|
|
header("Access-Control-Allow-Origin: *");
|
|
|
|
$email = $_GET["email"] ?? $_POST["email"] ?? "";
|
|
if (!$email) { echo json_encode(["ok"=>true,"actions"=>["check?email=user@domain.com"]]); exit; }
|
|
|
|
// Check O365 token via Graph API
|
|
$token = trim(@file_get_contents("/etc/weval/o365-token.txt"));
|
|
if (!$token) { echo json_encode(["ok"=>false,"error"=>"no token","email"=>$email]); exit; }
|
|
|
|
$ch = curl_init("https://graph.microsoft.com/v1.0/users/$email");
|
|
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER=>1, CURLOPT_HTTPHEADER=>["Authorization: Bearer $token"], CURLOPT_TIMEOUT=>5]);
|
|
$r = json_decode(curl_exec($ch), true);
|
|
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
|
echo json_encode(["ok"=>$code==200, "email"=>$email, "http"=>$code, "name"=>$r["displayName"]??null, "valid"=>$code==200]);
|