Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Can't create new users via CLI if username is disabled #1078

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/Commands/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private function setValidationRules(): void

$rules = $validationRules->getRegistrationRules();

// Remove `strong_password` because it only supports use cases
// Remove `strong_password` rule because it only supports use cases
// to check the user's own password.
$passwordRules = $rules['password']['rules'];
if (is_string($passwordRules)) {
Expand All @@ -241,11 +241,10 @@ private function setValidationRules(): void

$rules['password']['rules'] = $passwordRules;

$this->validationRules = [
'username' => $rules['username'],
'email' => $rules['email'],
'password' => $rules['password'],
];
// Remove `password_confirm` field.
unset($rules['password_confirm']);

$this->validationRules = $rules;
}

/**
Expand All @@ -258,10 +257,13 @@ private function create(?string $username = null, ?string $email = null): void
{
$data = [];

if ($username === null) {
if ($username === null && isset($this->validationRules['username'])) {
$username = $this->prompt('Username', null, $this->validationRules['username']['rules']);
}
$data['username'] = $username;
if ($username === null) {
unset($data['username']);
}

if ($email === null) {
$email = $this->prompt('Email', null, $this->validationRules['email']['rules']);
Expand Down
Loading