-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66229d4
commit 4d0c53a
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace RockShell; | ||
|
||
use ProcessWire\WireRandom; | ||
use Symfony\Component\Console\Input\InputOption; | ||
|
||
class PwPass extends Command | ||
{ | ||
|
||
public function config() | ||
{ | ||
$this | ||
->setDescription("Reset passwort of a user") | ||
->addOption("user", "u", InputOption::VALUE_OPTIONAL, "username"); | ||
} | ||
|
||
public function handle() | ||
{ | ||
if (!$user = $this->option('user')) { | ||
$users = []; | ||
foreach ($this->wire()->users as $u) $users[] = $u->name; | ||
$user = $this->choice("Select user", $users); | ||
} | ||
|
||
$rand = new WireRandom(); | ||
$pass = $rand->alphanumeric(0, [ | ||
'maxLength' => 20, | ||
'minLength' => 12, | ||
]); | ||
$pass = $this->ask("Enter Password", $pass); | ||
|
||
$user = $this->wire()->users->get("name=$user"); | ||
$user->setAndSave('pass', $pass); | ||
|
||
$this->success("Password set for user " . $user->name . "."); | ||
return self::SUCCESS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace RockShell; | ||
|
||
class PwUsers extends Command | ||
{ | ||
|
||
public function config() | ||
{ | ||
$this | ||
->setDescription("List all users"); | ||
} | ||
|
||
public function handle() | ||
{ | ||
foreach ($this->wire()->users as $u) { | ||
$this->write("{$u->name} ($u)"); | ||
} | ||
return self::SUCCESS; | ||
} | ||
} |