2024-08-10 00:39:26 +08:00
|
|
|
|
<?php
|
|
|
|
|
if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
2024-08-10 00:51:17 +08:00
|
|
|
|
if(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 метод',
|
|
|
|
|
];
|
|
|
|
|
}
|