2024-08-10 00:39:26 +08:00
|
|
|
|
<?php
|
|
|
|
|
if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
2024-08-10 01:02:13 +08:00
|
|
|
|
if(!isset($_REQUEST['login'])) {
|
|
|
|
|
$data = [
|
|
|
|
|
'error' => true,
|
|
|
|
|
'message' => 'Не передано поле login',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
elseif(!isset($_REQUEST['password'])) {
|
|
|
|
|
$data = [
|
|
|
|
|
'error' => true,
|
|
|
|
|
'message' => 'Не передано поле password',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
elseif(strlen($_REQUEST['password']) < 8) {
|
2024-08-10 00:39:26 +08:00
|
|
|
|
$data = [
|
|
|
|
|
'error' => true,
|
|
|
|
|
'message' => 'Пароль должен иметь 8 символов минимум',
|
|
|
|
|
];
|
|
|
|
|
}
|
2024-08-10 00:51:17 +08:00
|
|
|
|
elseif(!User::create($_REQUEST['login'], $_REQUEST['password'])) {
|
2024-08-10 00:39:26 +08:00
|
|
|
|
$data = [
|
|
|
|
|
'error' => true,
|
|
|
|
|
'message' => 'Пользователь с таким логином уже сужествует',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$data = [
|
|
|
|
|
'error' => false,
|
|
|
|
|
'message' => 'Пользователь создан',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$data = [
|
|
|
|
|
'error' => true,
|
|
|
|
|
'message' => 'Только POST метод',
|
|
|
|
|
];
|
|
|
|
|
}
|