|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* NOTICE OF LICENSE |
|
5
|
|
|
* |
|
6
|
|
|
* Part of the Rinvex Fort Package. |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to The MIT License (MIT) |
|
9
|
|
|
* that is bundled with this package in the LICENSE file. |
|
10
|
|
|
* |
|
11
|
|
|
* Package: Rinvex Fort Package |
|
12
|
|
|
* License: The MIT License (MIT) |
|
13
|
|
|
* Link: https://rinvex.com |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace Rinvex\Fort\Console\Commands; |
|
17
|
|
|
|
|
18
|
|
|
use Illuminate\Mail\Message; |
|
19
|
|
|
use Illuminate\Console\Command; |
|
20
|
|
|
use Illuminate\Support\Facades\Lang; |
|
21
|
|
|
|
|
22
|
|
|
class UserRemindCommand extends Command |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* The name and signature of the console command. |
|
26
|
|
|
* |
|
27
|
|
|
* @var string |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $signature = 'fort:user:remind |
|
30
|
|
|
{user? : The user identifier} |
|
31
|
|
|
{action? : The action to remind user of} |
|
32
|
|
|
{broker? : The name of the password broker}'; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* The console command description. |
|
36
|
|
|
* |
|
37
|
|
|
* @var string |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $description = 'Remind user to take action (reset password, verify email).'; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Execute the console command. |
|
43
|
|
|
* |
|
44
|
|
|
* @return void |
|
45
|
|
|
*/ |
|
46
|
|
|
public function handle() |
|
47
|
|
|
{ |
|
48
|
|
|
$userField = $this->argument('user') ?: $this->ask(Lang::get('rinvex.fort::artisan.user.identifier')); |
|
49
|
|
|
|
|
50
|
|
|
if (intval($userField)) { |
|
51
|
|
|
$user = $this->laravel['rinvex.fort.user']->find($userField); |
|
52
|
|
|
} else if (filter_var($userField, FILTER_VALIDATE_EMAIL)) { |
|
53
|
|
|
$user = $this->laravel['rinvex.fort.user']->findWhere(['email' => $userField])->first(); |
|
54
|
|
|
} else { |
|
55
|
|
|
$user = $this->laravel['rinvex.fort.user']->findWhere(['username' => $userField])->first(); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
if (! $user) { |
|
59
|
|
|
return $this->error(Lang::get('rinvex.fort::artisan.user.invalid', ['field' => $userField])); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
$actionField = $this->argument('action') ?: $this->anticipate(Lang::get('rinvex.fort::artisan.user.action'), ['resetpassword', 'verification']); |
|
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
switch ($actionField) { |
|
66
|
|
|
case 'resetpassword': |
|
67
|
|
|
$this->laravel['rinvex.fort.resetter']->broker($this->argument('broker'))->sendResetLink(['email' => $user->email]); |
|
|
|
|
|
|
68
|
|
|
return $this->info(Lang::get('rinvex.fort::artisan.user.resetpassword')); |
|
69
|
|
|
break; |
|
|
|
|
|
|
70
|
|
|
|
|
71
|
|
|
case 'verification': |
|
72
|
|
|
$this->laravel['rinvex.fort.verifier']->broker($this->argument('broker'))->sendVerificationLink(['email' => $user->email]); |
|
|
|
|
|
|
73
|
|
|
return $this->info(Lang::get('rinvex.fort::artisan.user.verification')); |
|
74
|
|
|
break; |
|
|
|
|
|
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
return $this->error(Lang::get('rinvex.fort::artisan.user.invalidaction')); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.