1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace plunner\Http\Controllers\Employees\Auth; |
4
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
6
|
|
|
use plunner\Company; |
7
|
|
|
use plunner\Http\Controllers\Controller; |
8
|
|
|
use Tymon\JWTAuth\Support\auth\ResetsPasswords; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class PasswordController |
12
|
|
|
* @package plunner\Http\Controllers\Employees\Auth |
13
|
|
|
* @author Claudio Cardinale <[email protected]> |
14
|
|
|
* @copyright 2015 Claudio Cardinale |
15
|
|
|
* @version 1.0.0 |
16
|
|
|
*/ |
17
|
|
|
class PasswordController extends Controller |
18
|
|
|
{ |
19
|
|
|
/* |
20
|
|
|
|-------------------------------------------------------------------------- |
21
|
|
|
| Password Reset Controller |
22
|
|
|
|-------------------------------------------------------------------------- |
23
|
|
|
| |
24
|
|
|
| This controller is responsible for handling password reset requests |
25
|
|
|
| and uses a simple trait to include this behavior. You're free to |
26
|
|
|
| explore this trait and override any methods you wish to tweak. |
27
|
|
|
| |
28
|
|
|
*/ |
29
|
|
|
|
30
|
|
|
use ResetsPasswords { |
31
|
|
|
postEmail as postEmailOriginal; |
32
|
|
|
postReset as postResetOriginal; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* en = employee normal |
37
|
|
|
* @var array |
38
|
|
|
*/ |
39
|
|
|
protected $custom = ['mode' => 'en']; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var array |
43
|
|
|
*/ |
44
|
|
|
protected $username = ['email', 'company_id']; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var company |
48
|
|
|
*/ |
49
|
|
|
private $company = null; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Create a new password controller instance. |
53
|
|
|
* |
54
|
|
|
*/ |
55
|
6 |
|
public function __construct() |
56
|
|
|
{ |
57
|
6 |
|
config(['auth.model' => \plunner\Employee::class]); |
58
|
6 |
|
config(['jwt.user' => \plunner\Employee::class]); |
59
|
6 |
|
config(['auth.password.table' => 'password_resets_employees', 'auth.password.email' => 'emails.employees.password']); |
60
|
6 |
|
} |
61
|
|
|
|
62
|
6 |
|
public function postEmail(Request $request) |
63
|
|
|
{ |
64
|
6 |
|
$this->validate($request, ['company' => 'required|exists:companies,name']); |
65
|
6 |
|
$this->company = Company::whereName($request->input('company'))->firstOrFail(); |
66
|
6 |
|
$request->merge(['company_id' => $this->company->id]); |
67
|
6 |
|
return $this->postEmailOriginal($request); |
68
|
|
|
} |
69
|
|
|
|
70
|
3 |
|
public function postReset(Request $request) |
71
|
|
|
{ |
72
|
3 |
|
$this->validate($request, ['company' => 'required|exists:companies,name']); |
73
|
3 |
|
$this->company = Company::whereName($request->input('company'))->firstOrFail(); |
74
|
3 |
|
$request->merge(['company_id' => $this->company->id]); |
75
|
3 |
|
return $this->postResetOriginal($request); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
|
79
|
|
|
} |
80
|
|
|
|