@@ -25,14 +25,14 @@ |
||
25 | 25 | public function handle($request, \Closure $next, $custom = '') |
26 | 26 | { |
27 | 27 | $remember = false; |
28 | - if($this->auth->setRequest($request)->getToken() && $remember = $this->auth->getPayload()->get('remember') && |
|
29 | - $remember == 'true'){ |
|
30 | - config(['jwt.ttl' =>'43200']); //30 days |
|
28 | + if ($this->auth->setRequest($request)->getToken() && $remember = $this->auth->getPayload()->get('remember') && |
|
29 | + $remember == 'true') { |
|
30 | + config([ 'jwt.ttl' =>'43200' ]); //30 days |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | //this to add the remember me mode field in the new token, but we have the custom check that is an useless |
34 | 34 | //overhead |
35 | - $custom = $custom.';remember-'.$remember?'true':'false'; |
|
35 | + $custom = $custom.';remember-'.$remember ? 'true' : 'false'; |
|
36 | 36 | return parent::handle($request, $next, $custom); |
37 | 37 | } |
38 | 38 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * en = employee normal |
44 | 44 | * @var array |
45 | 45 | */ |
46 | - protected $custom = ['mode'=>'en']; |
|
46 | + protected $custom = [ 'mode'=>'en' ]; |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @var company |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function __construct() |
58 | 58 | { |
59 | - config(['auth.model' => \plunner\Employee::class]); |
|
60 | - config(['jwt.user' => \plunner\Employee::class]); |
|
59 | + config([ 'auth.model' => \plunner\Employee::class ]); |
|
60 | + config([ 'jwt.user' => \plunner\Employee::class ]); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -84,15 +84,15 @@ discard block |
||
84 | 84 | protected function create(array $data) |
85 | 85 | { |
86 | 86 | return $this->company->save(new employee([ |
87 | - 'name' => $data['name'], |
|
88 | - 'email' => $data['email'], |
|
89 | - 'password' => bcrypt($data['password']), |
|
87 | + 'name' => $data[ 'name' ], |
|
88 | + 'email' => $data[ 'email' ], |
|
89 | + 'password' => bcrypt($data[ 'password' ]), |
|
90 | 90 | ])); |
91 | 91 | } |
92 | 92 | |
93 | 93 | public function postRegister(Request $request) |
94 | 94 | { |
95 | - $this->validate($request, ['company' => 'required|exists:companies,name']); |
|
95 | + $this->validate($request, [ 'company' => 'required|exists:companies,name' ]); |
|
96 | 96 | $this->company = Company::whereName($request->input('company'))->firstOrFail(); |
97 | 97 | return $this->postRegisterOriginal($request); |
98 | 98 | } |
@@ -101,18 +101,18 @@ discard block |
||
101 | 101 | public function postLogin(Request $request) |
102 | 102 | { |
103 | 103 | //get company ID and impiled it in the request |
104 | - $this->validate($request, ['company' => 'required|exists:companies,name']); |
|
104 | + $this->validate($request, [ 'company' => 'required|exists:companies,name' ]); |
|
105 | 105 | $this->company = Company::whereName($request->input('company'))->firstOrFail(); |
106 | - $request->merge(['company_id' => $this->company->id]); |
|
106 | + $request->merge([ 'company_id' => $this->company->id ]); |
|
107 | 107 | |
108 | 108 | //remember me |
109 | - $this->validate($request, ['remember' => 'boolean']);//TODO insert required |
|
110 | - if($request->input('remember', false)) |
|
109 | + $this->validate($request, [ 'remember' => 'boolean' ]); //TODO insert required |
|
110 | + if ($request->input('remember', false)) |
|
111 | 111 | { |
112 | - config(['jwt.ttl' =>'43200']); //30 days |
|
113 | - $this->custom = array_merge($this->custom, ['remember'=>'true']); |
|
114 | - }else |
|
115 | - $this->custom = array_merge($this->custom, ['remember'=>'false']); |
|
112 | + config([ 'jwt.ttl' =>'43200' ]); //30 days |
|
113 | + $this->custom = array_merge($this->custom, [ 'remember'=>'true' ]); |
|
114 | + } else |
|
115 | + $this->custom = array_merge($this->custom, [ 'remember'=>'false' ]); |
|
116 | 116 | |
117 | 117 | return $this->postLoginOriginal($request); |
118 | 118 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * cn = company normal |
41 | 41 | * @var array |
42 | 42 | */ |
43 | - protected $custom = ['mode'=>'cn']; |
|
43 | + protected $custom = [ 'mode'=>'cn' ]; |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * Create a new authentication controller instance. |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function __construct() |
50 | 50 | { |
51 | - config(['auth.model' => \plunner\Company::class]); |
|
52 | - config(['jwt.user' => \plunner\Company::class]); |
|
51 | + config([ 'auth.model' => \plunner\Company::class ]); |
|
52 | + config([ 'jwt.user' => \plunner\Company::class ]); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -76,22 +76,22 @@ discard block |
||
76 | 76 | protected function create(array $data) |
77 | 77 | { |
78 | 78 | return Company::create([ |
79 | - 'name' => $data['name'], |
|
80 | - 'email' => $data['email'], |
|
81 | - 'password' => bcrypt($data['password']), |
|
79 | + 'name' => $data[ 'name' ], |
|
80 | + 'email' => $data[ 'email' ], |
|
81 | + 'password' => bcrypt($data[ 'password' ]), |
|
82 | 82 | ]); |
83 | 83 | } |
84 | 84 | |
85 | 85 | public function postLogin(Request $request) |
86 | 86 | { |
87 | 87 | //remember me |
88 | - $this->validate($request, ['remember' => 'boolean']);//TODO insert required |
|
89 | - if($request->input('remember', false)) |
|
88 | + $this->validate($request, [ 'remember' => 'boolean' ]); //TODO insert required |
|
89 | + if ($request->input('remember', false)) |
|
90 | 90 | { |
91 | - config(['jwt.ttl' =>'43200']); //30 days |
|
92 | - $this->custom = array_merge($this->custom, ['remember'=>'true']); |
|
93 | - }else |
|
94 | - $this->custom = array_merge($this->custom, ['remember'=>'false']); |
|
91 | + config([ 'jwt.ttl' =>'43200' ]); //30 days |
|
92 | + $this->custom = array_merge($this->custom, [ 'remember'=>'true' ]); |
|
93 | + } else |
|
94 | + $this->custom = array_merge($this->custom, [ 'remember'=>'false' ]); |
|
95 | 95 | return $this->postLoginOriginal($request); |
96 | 96 | } |
97 | 97 |
@@ -30,6 +30,6 @@ |
||
30 | 30 | 'auth' => \plunner\Http\Middleware\Authenticate::class, |
31 | 31 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, |
32 | 32 | 'guest' => \plunner\Http\Middleware\RedirectIfAuthenticated::class, |
33 | - 'jwt.authandrefresh' => \plunner\Http\Middleware\GetUserAndRefresh::class,//'Tymon\JWTAuth\Middleware\GetUserAndRefresh', |
|
33 | + 'jwt.authandrefresh' => \plunner\Http\Middleware\GetUserAndRefresh::class, //'Tymon\JWTAuth\Middleware\GetUserAndRefresh', |
|
34 | 34 | ]; |
35 | 35 | } |