mirror of
git://f0xx.org/ac/ac-ms-identity
synced 2026-07-30 03:38:12 +03:00
initial
This commit is contained in:
26
public/api/auth_register.php
Normal file
26
public/api/auth_register.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../../src/bootstrap.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
json_out(['ok' => false, 'error' => 'method_not_allowed'], 405);
|
||||
}
|
||||
|
||||
$raw = file_get_contents('php://input');
|
||||
$data = json_decode($raw ?: '', true);
|
||||
if (!is_array($data)) {
|
||||
json_out(['ok' => false, 'error' => 'invalid_json'], 400);
|
||||
}
|
||||
|
||||
$action = (string) ($data['action'] ?? 'register');
|
||||
if ($action === 'verify') {
|
||||
$result = AuthRegistration::verifyEmailToken((string) ($data['token'] ?? ''));
|
||||
json_out($result, $result['ok'] ? 200 : 400);
|
||||
}
|
||||
|
||||
$email = (string) ($data['email'] ?? '');
|
||||
$password = (string) ($data['password'] ?? '');
|
||||
$username = (string) ($data['username'] ?? '');
|
||||
$result = AuthRegistration::register($email, $password, $username);
|
||||
json_out($result, $result['ok'] ? 200 : 400);
|
||||
Reference in New Issue
Block a user