@@ -37,7 +37,7 @@ |
||
37 | 37 | */ |
38 | 38 | public function map(Router $router) |
39 | 39 | { |
40 | - $router->group(['namespace' => $this->namespace], function ($router) { |
|
40 | + $router->group([ 'namespace' => $this->namespace ], function($router) { |
|
41 | 41 | require app_path('Http/routes.php'); |
42 | 42 | }); |
43 | 43 | } |
@@ -2,11 +2,11 @@ |
||
2 | 2 | |
3 | 3 | namespace plunner\Http\Controllers\Companies\Auth; |
4 | 4 | |
5 | -use plunner\Company; |
|
6 | -use Validator; |
|
7 | -use plunner\Http\Controllers\Controller; |
|
8 | 5 | use Tymon\JWTAuth\Support\auth\AuthenticatesAndRegistersUsers; |
9 | 6 | use Tymon\JWTAuth\Support\auth\ThrottlesLogins; |
7 | +use Validator; |
|
8 | +use plunner\Company; |
|
9 | +use plunner\Http\Controllers\Controller; |
|
10 | 10 | |
11 | 11 | class AuthController extends Controller |
12 | 12 | { |
@@ -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 |
@@ -90,8 +90,9 @@ |
||
90 | 90 | { |
91 | 91 | config(['jwt.ttl' =>'43200']); //30 days |
92 | 92 | $this->custom = array_merge($this->custom, ['remember'=>'true']); |
93 | - }else |
|
94 | - $this->custom = array_merge($this->custom, ['remember'=>'false']); |
|
93 | + } else { |
|
94 | + $this->custom = array_merge($this->custom, ['remember'=>'false']); |
|
95 | + } |
|
95 | 96 | return $this->postLoginOriginal($request); |
96 | 97 | } |
97 | 98 |
@@ -3,13 +3,12 @@ |
||
3 | 3 | namespace plunner\Http\Controllers\Employees\Auth; |
4 | 4 | |
5 | 5 | use Illuminate\Http\Request; |
6 | -use plunner\Company; |
|
7 | -use plunner\employee; |
|
8 | -use Validator; |
|
9 | -use plunner\Http\Controllers\Controller; |
|
10 | 6 | use Tymon\JWTAuth\Support\auth\AuthenticatesAndRegistersUsers; |
11 | 7 | use Tymon\JWTAuth\Support\auth\ThrottlesLogins; |
12 | -use Log; |
|
8 | +use Validator; |
|
9 | +use plunner\Company; |
|
10 | +use plunner\Http\Controllers\Controller; |
|
11 | +use plunner\employee; |
|
13 | 12 | |
14 | 13 | class AuthController extends Controller |
15 | 14 | { |
@@ -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 | } |
@@ -90,8 +90,9 @@ |
||
90 | 90 | { |
91 | 91 | config(['jwt.ttl' =>'43200']); //30 days |
92 | 92 | $this->custom = array_merge($this->custom, ['remember'=>'true']); |
93 | - }else |
|
94 | - $this->custom = array_merge($this->custom, ['remember'=>'false']); |
|
93 | + } else { |
|
94 | + $this->custom = array_merge($this->custom, ['remember'=>'false']); |
|
95 | + } |
|
95 | 96 | return $this->postLoginOriginal($request); |
96 | 97 | } |
97 | 98 |
@@ -3,8 +3,8 @@ |
||
3 | 3 | namespace plunner\Http\Controllers\Employees\Auth; |
4 | 4 | |
5 | 5 | use Illuminate\Http\Request; |
6 | -use plunner\Http\Controllers\Controller; |
|
7 | 6 | use Tymon\JWTAuth\Support\auth\ResetsPasswords; |
7 | +use plunner\Http\Controllers\Controller; |
|
8 | 8 | use \plunner\Company; |
9 | 9 | use \plunner\Employee; |
10 | 10 |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | * en = employee normal |
39 | 39 | * @var array |
40 | 40 | */ |
41 | - protected $custom = ['mode'=>'en']; |
|
41 | + protected $custom = [ 'mode'=>'en' ]; |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @var array |
45 | 45 | */ |
46 | - protected $username = ['email', 'company_id']; |
|
46 | + protected $username = [ 'email', 'company_id' ]; |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @var company |
@@ -57,24 +57,24 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function __construct() |
59 | 59 | { |
60 | - config(['auth.model' => \plunner\Employee::class]); |
|
61 | - config(['jwt.user' => \plunner\Employee::class]); |
|
62 | - config(['auth.password.table' => 'password_resets_employees', 'auth.password.email' => 'emails.employees.password']); |
|
60 | + config([ 'auth.model' => \plunner\Employee::class ]); |
|
61 | + config([ 'jwt.user' => \plunner\Employee::class ]); |
|
62 | + config([ 'auth.password.table' => 'password_resets_employees', 'auth.password.email' => 'emails.employees.password' ]); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | public function postEmail(Request $request) |
66 | 66 | { |
67 | - $this->validate($request, ['company' => 'required|exists:companies,name']); |
|
67 | + $this->validate($request, [ 'company' => 'required|exists:companies,name' ]); |
|
68 | 68 | $this->company = Company::whereName($request->input('company'))->firstOrFail(); |
69 | - $request->merge(['company_id' => $this->company->id]); |
|
69 | + $request->merge([ 'company_id' => $this->company->id ]); |
|
70 | 70 | return $this->postEmailOriginal($request); |
71 | 71 | } |
72 | 72 | |
73 | 73 | public function postReset(Request $request) |
74 | 74 | { |
75 | - $this->validate($request, ['company' => 'required|exists:companies,name']); |
|
75 | + $this->validate($request, [ 'company' => 'required|exists:companies,name' ]); |
|
76 | 76 | $this->company = Company::whereName($request->input('company'))->firstOrFail(); |
77 | - $request->merge(['company_id' => $this->company->id]); |
|
77 | + $request->merge([ 'company_id' => $this->company->id ]); |
|
78 | 78 | return $this->postResetOriginal($request); |
79 | 79 | } |
80 | 80 |
@@ -20,8 +20,8 @@ |
||
20 | 20 | */ |
21 | 21 | public function __construct() |
22 | 22 | { |
23 | - config(['auth.model' => \plunner\Company::class]); |
|
24 | - config(['jwt.user' => \plunner\Company::class]); |
|
23 | + config([ 'auth.model' => \plunner\Company::class ]); |
|
24 | + config([ 'jwt.user' => \plunner\Company::class ]); |
|
25 | 25 | $this->middleware('jwt.authandrefresh:mode-cn'); |
26 | 26 | } |
27 | 27 |
@@ -1,21 +1,21 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Created by PhpStorm. |
|
4 | - * User: Claudio Cardinale <[email protected]> |
|
5 | - * Date: 24/11/15 |
|
6 | - * Time: 21.58 |
|
7 | - * This program is free software; you can redistribute it and/or |
|
8 | - * modify it under the terms of the GNU General Public License |
|
9 | - * as published by the Free Software Foundation; either version 2 |
|
10 | - * of the License, or (at your option) any later version. |
|
11 | - * This program is distributed in the hope that it will be useful, |
|
12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 | - * GNU General Public License for more details. |
|
15 | - * You should have received a copy of the GNU General Public License |
|
16 | - * along with this program; if not, write to the Free Software |
|
17 | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
18 | - */ |
|
3 | + * Created by PhpStorm. |
|
4 | + * User: Claudio Cardinale <[email protected]> |
|
5 | + * Date: 24/11/15 |
|
6 | + * Time: 21.58 |
|
7 | + * This program is free software; you can redistribute it and/or |
|
8 | + * modify it under the terms of the GNU General Public License |
|
9 | + * as published by the Free Software Foundation; either version 2 |
|
10 | + * of the License, or (at your option) any later version. |
|
11 | + * This program is distributed in the hope that it will be useful, |
|
12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 | + * GNU General Public License for more details. |
|
15 | + * You should have received a copy of the GNU General Public License |
|
16 | + * along with this program; if not, write to the Free Software |
|
17 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
18 | + */ |
|
19 | 19 | |
20 | 20 | namespace plunner; |
21 | 21 |
@@ -51,8 +51,9 @@ |
||
51 | 51 | |
52 | 52 | public function getPlannerNameAttribute() |
53 | 53 | { |
54 | - if(is_object($this->planner) && $this->planner->exists) |
|
55 | - return $this->planner->name; |
|
54 | + if(is_object($this->planner) && $this->planner->exists) { |
|
55 | + return $this->planner->name; |
|
56 | + } |
|
56 | 57 | } |
57 | 58 | |
58 | 59 | /** |
@@ -44,21 +44,21 @@ |
||
44 | 44 | * |
45 | 45 | * @var array |
46 | 46 | */ |
47 | - protected $fillable = ['name', 'description', 'planner_id']; |
|
47 | + protected $fillable = [ 'name', 'description', 'planner_id' ]; |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @var array |
51 | 51 | */ |
52 | - protected $hidden = ['planner', 'pivot']; |
|
52 | + protected $hidden = [ 'planner', 'pivot' ]; |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @var array |
56 | 56 | */ |
57 | - protected $appends = ['planner_name']; |
|
57 | + protected $appends = [ 'planner_name' ]; |
|
58 | 58 | |
59 | 59 | public function getPlannerNameAttribute() |
60 | 60 | { |
61 | - if(is_object($this->planner) && $this->planner->exists) |
|
61 | + if (is_object($this->planner) && $this->planner->exists) |
|
62 | 62 | return $this->planner->name; |
63 | 63 | return null; |
64 | 64 | } |
@@ -3,8 +3,8 @@ |
||
3 | 3 | namespace plunner\Http\Controllers\Companies\Groups; |
4 | 4 | |
5 | 5 | use Illuminate\Support\Facades\Response; |
6 | -use plunner\Group; |
|
7 | 6 | use plunner\Employee; |
7 | +use plunner\Group; |
|
8 | 8 | use plunner\Http\Controllers\Controller; |
9 | 9 | use plunner\Http\Requests\Companies\Groups\EmployeeRequest; |
10 | 10 |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function __construct() |
23 | 23 | { |
24 | - config(['auth.model' => \plunner\Company::class]); |
|
25 | - config(['jwt.user' => \plunner\Company::class]); |
|
24 | + config([ 'auth.model' => \plunner\Company::class ]); |
|
25 | + config([ 'jwt.user' => \plunner\Company::class ]); |
|
26 | 26 | $this->middleware('jwt.authandrefresh:mode-cn'); |
27 | 27 | } |
28 | 28 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | // |
54 | 54 | $group = Group::findOrFail($groupId); |
55 | 55 | $this->authorize($group); |
56 | - $id = $request->all()['id']; |
|
56 | + $id = $request->all()[ 'id' ]; |
|
57 | 57 | $group->employees()->attach($id); |
58 | 58 | return $group->employees; |
59 | 59 | } |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | $employee = Employee::findOrFail($employeeId); |
72 | 72 | $this->authorize($employee); |
73 | 73 | $group = Group::findOrFail($groupId); |
74 | - if(!$employee->belongsToGroup($group)) |
|
75 | - return Response::json(['error' => 'employId <> groupId'],404); |
|
74 | + if (!$employee->belongsToGroup($group)) |
|
75 | + return Response::json([ 'error' => 'employId <> groupId' ], 404); |
|
76 | 76 | $employee->groups()->detach($groupId); |
77 | 77 | return $group->employees; |
78 | 78 | } |
@@ -71,8 +71,9 @@ |
||
71 | 71 | $employee = Employee::findOrFail($employeeId); |
72 | 72 | $this->authorize($employee); |
73 | 73 | $group = Group::findOrFail($groupId); |
74 | - if(!$employee->belongsToGroup($group)) |
|
75 | - return Response::json(['error' => 'employId <> groupId'],404); |
|
74 | + if(!$employee->belongsToGroup($group)) { |
|
75 | + return Response::json(['error' => 'employId <> groupId'],404); |
|
76 | + } |
|
76 | 77 | $employee->groups()->detach($groupId); |
77 | 78 | return $group->employees; |
78 | 79 | } |
@@ -2,12 +2,12 @@ |
||
2 | 2 | |
3 | 3 | namespace plunner; |
4 | 4 | |
5 | -use Illuminate\Database\Eloquent\Model; |
|
6 | 5 | use Illuminate\Auth\Authenticatable; |
7 | 6 | use Illuminate\Auth\Passwords\CanResetPassword; |
8 | 7 | use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; |
9 | 8 | use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; |
10 | 9 | use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; |
10 | +use Illuminate\Database\Eloquent\Model; |
|
11 | 11 | use Illuminate\Foundation\Auth\Access\Authorizable; |
12 | 12 | |
13 | 13 | /** |
@@ -50,19 +50,19 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @var array |
52 | 52 | */ |
53 | - protected $fillable = ['name', 'email', 'password']; |
|
53 | + protected $fillable = [ 'name', 'email', 'password' ]; |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * The attributes excluded from the model's JSON form. |
57 | 57 | * |
58 | 58 | * @var array |
59 | 59 | */ |
60 | - protected $hidden = ['password', 'remember_token', 'pivot']; |
|
60 | + protected $hidden = [ 'password', 'remember_token', 'pivot' ]; |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * @var array |
64 | 64 | */ |
65 | - protected $appends = ['is_planner']; |
|
65 | + protected $appends = [ 'is_planner' ]; |
|
66 | 66 | |
67 | 67 | public function getIsPlannerAttribute() |
68 | 68 | { |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * to get all meetings where the user can go user groups with meetings |
99 | 99 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
100 | 100 | */ |
101 | - public function meetings(){ |
|
101 | + public function meetings() { |
|
102 | 102 | //TODO durign the inserting chek if the meeting is of a group of the user |
103 | 103 | return $this->belongsToMany(Meeting::class); |
104 | 104 | } |
@@ -114,16 +114,16 @@ discard block |
||
114 | 114 | public function getEmailForPasswordReset() |
115 | 115 | { |
116 | 116 | list(, $caller) = debug_backtrace(false); |
117 | - if(isset($caller['class'])) |
|
118 | - $caller = explode('\\', $caller['class']); |
|
117 | + if (isset($caller[ 'class' ])) |
|
118 | + $caller = explode('\\', $caller[ 'class' ]); |
|
119 | 119 | else |
120 | 120 | $caller = ''; |
121 | 121 | |
122 | 122 | //check if this function is called by email sender |
123 | - if ((count($caller) && $caller[count($caller) - 1] == 'PasswordBroker') || (defined('HHVM_VERSION') && $caller == '')) |
|
123 | + if ((count($caller) && $caller[ count($caller) - 1 ] == 'PasswordBroker') || (defined('HHVM_VERSION') && $caller == '')) |
|
124 | 124 | return $this->email; |
125 | 125 | //return unique identify for token repository |
126 | - return $this->email . $this->company->id; |
|
126 | + return $this->email.$this->company->id; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -114,14 +114,16 @@ |
||
114 | 114 | public function getEmailForPasswordReset() |
115 | 115 | { |
116 | 116 | list(, $caller) = debug_backtrace(false); |
117 | - if(isset($caller['class'])) |
|
118 | - $caller = explode('\\', $caller['class']); |
|
119 | - else |
|
120 | - $caller = ''; |
|
117 | + if(isset($caller['class'])) { |
|
118 | + $caller = explode('\\', $caller['class']); |
|
119 | + } else { |
|
120 | + $caller = ''; |
|
121 | + } |
|
121 | 122 | |
122 | 123 | //check if this function is called by email sender |
123 | - if ((count($caller) && $caller[count($caller) - 1] == 'PasswordBroker') || (defined('HHVM_VERSION') && $caller == '')) |
|
124 | - return $this->email; |
|
124 | + if ((count($caller) && $caller[count($caller) - 1] == 'PasswordBroker') || (defined('HHVM_VERSION') && $caller == '')) { |
|
125 | + return $this->email; |
|
126 | + } |
|
125 | 127 | //return unique identify for token repository |
126 | 128 | return $this->email . $this->company->id; |
127 | 129 | } |