user_pref_language users field value changed to enum. user_phone_number optional.
This commit is contained in:
@@ -20,28 +20,28 @@ if ($API_users->request_method === 'GET') {
|
||||
'user_email' => ['type' => 'email'],
|
||||
'user_first_name' => ['type' => 'string'],
|
||||
'user_last_name' => ['type' => 'string'],
|
||||
'user_full_name' => ['type' => 'string'],
|
||||
'user_phone_number' => ['type' => 'string'],
|
||||
'user_status' => ['type' => 'enum', 'values' => ['active', 'inactive', 'banned', 'pending']],
|
||||
'user_password' => ['type' => 'string'],
|
||||
'user_pref_language' => ['type' => 'string'],
|
||||
'user_password_reset_token' => ['type' => 'string'],
|
||||
'user_password_reset_expires' => ['type' => 'int'],
|
||||
'user_full_name' => ['type' => 'string'], # Does not need to be posted, set later
|
||||
'user_status' => ['type' => 'enum', 'values' => ['inactive', 'banned', 'pending']],
|
||||
'user_password' => ['type' => 'string'], # Does not need to be posted, set later
|
||||
'user_pref_language' => ['type' => 'enum', 'values' => ['en', 'nl']],
|
||||
'user_password_reset_token' => ['type' => 'string'], # Does not need to be posted, set later
|
||||
'user_password_reset_expires' => ['type' => 'int'], # Does not need to be posted, set later
|
||||
];
|
||||
|
||||
# The user will need to verify their email, the password field cannot be NULL so set an random password for now till the user resets it on when verifing there email
|
||||
$optionalFields = [
|
||||
'user_phone_number' => ['type' => 'string']
|
||||
];
|
||||
|
||||
# The user will need to verify their email, the password field cannot be NULL so set a random password for now till the user resets it on when verifying there email
|
||||
$random_string = substr(str_shuffle(str_repeat('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01', 64)), 0, rand(50, 64));
|
||||
$user_password = password_hash($random_string, PASSWORD_BCRYPT, ["cost" => 12]);
|
||||
$API_users->postedData['user_password'] = $user_password;
|
||||
|
||||
$API_users->postedData['user_full_name'] = trim($_POST['user_first_name'] . ' ' . $_POST['user_last_name']);
|
||||
$API_users->postedData['user_pref_language'] = $_POST['user_pref_language'] ?? 'en';
|
||||
|
||||
# Password reset token that will be send to the newly created user
|
||||
# Password reset token that will be sent to the newly created user
|
||||
$API_users->postedData['user_password_reset_token'] = bin2hex(random_bytes(32));
|
||||
$API_users->postedData['user_password_reset_expires'] = time() + 86400;
|
||||
|
||||
$API_users->validateData($requiredFields);
|
||||
$API_users->validateData($requiredFields, $optionalFields);
|
||||
$API_users->createUser();
|
||||
|
||||
} elseif ($API_users->request_method === 'PUT') {
|
||||
@@ -56,9 +56,12 @@ if ($API_users->request_method === 'GET') {
|
||||
'user_first_name' => ['type' => 'string'],
|
||||
'user_last_name' => ['type' => 'string'],
|
||||
'user_full_name' => ['type' => 'string'],
|
||||
'user_phone_number' => ['type' => 'string'],
|
||||
'user_status' => ['type' => 'enum', 'values' => ['active', 'inactive', 'banned', 'pending']],
|
||||
'user_pref_language' => ['type' => 'string'],
|
||||
'user_pref_language' => ['type' => 'enum', 'values' => ['en', 'nl']],
|
||||
];
|
||||
|
||||
$optionalFields = [
|
||||
'user_phone_number' => ['type' => 'string'],
|
||||
'user_stompable' => ['type' => 'boolean']
|
||||
];
|
||||
|
||||
@@ -66,9 +69,7 @@ if ($API_users->request_method === 'GET') {
|
||||
$API_users->postedData['user_pref_language'] = $_POST['user_pref_language'] ?? 'en';
|
||||
$API_users->postedData['user_stompable'] = (bool)$_POST['user_stompable'];
|
||||
|
||||
|
||||
$API_users->validateData($requiredFields);
|
||||
|
||||
$API_users->validateData($requiredFields, $optionalFields);
|
||||
|
||||
$API_users->updateUser();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user