FEATURE: change directory structure

This commit is contained in:
Michal Kváček
2016-10-17 00:07:21 +02:00
parent 87f1920373
commit 2ded2924a1
242 changed files with 742 additions and 1171 deletions
+17 -9
View File
@@ -14,13 +14,13 @@ class ChangePassword extends Command
*
* @var string
*/
protected $signature = 'user:change-password {userID} {newPassword}';
protected $signature = 'user:change-password {email}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Change password for user with given ID';
protected $description = 'Change password for user with given e-mail';
/**
* Execute the console command.
@@ -29,18 +29,26 @@ class ChangePassword extends Command
*/
public function handle()
{
$id = $this->argument('userID');
$newPassword = $this->argument('newPassword');
$email = $this->argument('email');
try {
$user = User::findOrFail($id);
$user = User::where(['email' => $email])
->first();
} catch (ModelNotFoundException $e) {
$this->error('Invalid user ID ' . $id . '. Please see table `users` for correct IDs.');
exit(1);
$this->error('Invalid user ' . $email . '.');
return;
}
do {
$password = $this->secret('Password');
$passwordAgain = $this->secret('Password again');
if ($password !== $passwordAgain) {
$this->error('Passwords does not match');
}
} while ($passwordAgain !== $password || strlen($password) === 0);
// set new password
$user->password = Hash::make($newPassword);
$user->password = Hash::make($password);
$user->save();
$this->info('Password successfully changed.');