['At least 8 characters']]); } if (!password_verify($current, (string) $user['password'])) { json_error(422, 'Validation failed', ['current_password' => ['Wrong password']]); } $pdo->prepare('UPDATE auth_users SET password = ? WHERE id = ?') ->execute([password_hash($new, PASSWORD_DEFAULT), $user['id']]); // Keep the device that just changed the password signed in. $pdo->prepare('DELETE FROM api_tokens WHERE user_id = ? AND token <> ?') ->execute([$user['id'], hash('sha256', (string) bearer_token())]); json_ok();