Skip to content

Commit 4a4c34f

Browse files
authored
[Feature] Reset user password command (alexjustesen#719)
1 parent 4158815 commit 4a4c34f

File tree

4 files changed

+52
-2
lines changed

4 files changed

+52
-2
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Models\User;
6+
use Illuminate\Console\Command;
7+
use Illuminate\Support\Facades\Hash;
8+
9+
class ResetUserPassword extends Command
10+
{
11+
/**
12+
* The name and signature of the console command.
13+
*
14+
* @var string
15+
*/
16+
protected $signature = 'app:reset-user-password
17+
{email : The email address of the user}';
18+
19+
/**
20+
* The console command description.
21+
*
22+
* @var string
23+
*/
24+
protected $description = 'Reset the password for a user\'s account.';
25+
26+
/**
27+
* Execute the console command.
28+
*/
29+
public function handle()
30+
{
31+
$user = User::firstWhere('email', $this->argument('email'));
32+
33+
if (! $user) {
34+
// couldn't find the user so should fail.
35+
$this->error('Could not find a user with the email address of '.$$this->argument('email'));
36+
37+
Command::FAILURE;
38+
}
39+
40+
$password = $this->secret('What is the password?');
41+
42+
$user->update([
43+
'password' => Hash::make($password),
44+
]);
45+
46+
Command::SUCCESS;
47+
}
48+
}

app/Jobs/DeleteResultsData.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Illuminate\Queue\SerializesModels;
1414
use Illuminate\Support\Facades\DB;
1515

16-
class DeleteResultsData implements ShouldQueue, ShouldBeUnique
16+
class DeleteResultsData implements ShouldBeUnique, ShouldQueue
1717
{
1818
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
1919

app/Jobs/ExecSpeedtest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Symfony\Component\Process\Exception\ProcessFailedException;
1414
use Symfony\Component\Process\Process;
1515

16-
class ExecSpeedtest implements ShouldQueue, ShouldBeUnique
16+
class ExecSpeedtest implements ShouldBeUnique, ShouldQueue
1717
{
1818
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
1919

routes/web.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
Route::redirect('/', '/admin');
1717

18+
Route::redirect('/login', '/admin/login');
19+
1820
if (app()->isLocal()) {
1921
require __DIR__.'/test.php';
2022
}

0 commit comments

Comments
 (0)