Skip to content

Commit 3f6dae1

Browse files
authored
Merge pull request #417 from viralsolani/develop
Bug Fixes
2 parents c9cdb00 + df398ec commit 3f6dae1

File tree

16 files changed

+783
-481
lines changed

16 files changed

+783
-481
lines changed

.env.example

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
APP_NAME="Laravel Admin Panel"
2-
APP_SHORT_NAME="LAP"
1+
APP_DEMO=false
2+
APP_NAME="Laravel 5.8 AdminPanel"
33
APP_ENV=local
44
APP_KEY=
55
APP_DEBUG=true
6-
APP_LOG_LEVEL=debug
6+
DEBUGBAR_ENABLED=false
77
APP_URL=http://localhost
8-
8+
APP_LOCALE=en
9+
APP_FALLBACK_LOCALE=en
10+
APP_LOCALE_PHP=en_US
11+
APP_TIMEZONE=UTC
12+
LOG_CHANNEL=daily
13+
SINGLE_LOGIN=false
914

1015
DB_CONNECTION=mysql
1116
DB_HOST=127.0.0.1
@@ -14,34 +19,33 @@ DB_DATABASE=homestead
1419
DB_USERNAME=homestead
1520
DB_PASSWORD=secret
1621

17-
# Access
18-
ENABLE_REGISTRATION=true
19-
REQUIRES_APPROVAL=false
20-
2122
BROADCAST_DRIVER=log
2223
CACHE_DRIVER=file
2324
SESSION_DRIVER=file
2425
SESSION_LIFETIME=120
25-
QUEUE_DRIVER=sync
26-
27-
#Session Timeout
28-
SESSION_TIMEOUT_STATUS=true
29-
#In Seconds
30-
SESSION_TIMEOUT=600
26+
SESSION_ENCRYPT=false
27+
QUEUE_CONNECTION=sync
3128

3229
REDIS_HOST=127.0.0.1
3330
REDIS_PASSWORD=null
3431
REDIS_PORT=6379
3532

3633
MAIL_DRIVER=smtp
37-
MAIL_HOST=smtp.mailtrap.io
38-
MAIL_PORT=2525
39-
40-
MAIL_FROM_NAME=Admin
34+
MAIL_HOST=localhost
35+
MAIL_PORT=1025
4136
MAIL_USERNAME=null
4237
MAIL_PASSWORD=null
4338
MAIL_ENCRYPTION=null
4439

40+
AWS_ACCESS_KEY_ID=
41+
AWS_SECRET_ACCESS_KEY=
42+
AWS_DEFAULT_REGION=us-east-1
43+
AWS_BUCKET=
44+
4545
PUSHER_APP_ID=
4646
PUSHER_APP_KEY=
4747
PUSHER_APP_SECRET=
48+
PUSHER_APP_CLUSTER=mt1
49+
50+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
51+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

app/Exceptions/Handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function render($request, Exception $exception)
8888
*/
8989
if ($exception instanceof UnauthorizedHttpException) {
9090
switch (get_class($exception->getPrevious())) {
91-
case \App\Exceptions\Handler::class:
91+
case self::class:
9292
return $this->setStatusCode($exception->getStatusCode())->respondWithError('Token has not been provided.');
9393
}
9494
}

app/Http/Requests/Backend/Access/User/UpdateUserPasswordRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class UpdateUserPasswordRequest extends Request
1616
*/
1717
public function authorize()
1818
{
19-
return access()->allow('edit-user');
19+
return true;
2020
}
2121

2222
/**

app/Models/Access/User/User.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,6 @@ public function getJWTIdentifier()
7979
return $this->getKey();
8080
}
8181

82-
/**
83-
* Set password attribute.
84-
*
85-
* @param [string] $password
86-
*/
87-
public function setPasswordAttribute($password)
88-
{
89-
if (!empty($password)) {
90-
$this->attributes['password'] = bcrypt($password);
91-
}
92-
}
93-
9482
/**
9583
* Return a key value array, containing any custom claims to be added to the JWT.
9684
*

app/Repositories/Backend/Access/User/UserRepository.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ public function create($request)
9696
$permissions = $request->get('permissions');
9797
$user = $this->createUserStub($data);
9898

99+
$this->checkUserByEmail($data, $user);
100+
99101
DB::transaction(function () use ($user, $data, $roles, $permissions) {
100102
if ($user->save()) {
101103

@@ -175,7 +177,7 @@ public function updatePassword($user, $input)
175177
$user = $this->find(access()->id());
176178

177179
if (Hash::check($input['old_password'], $user->password)) {
178-
$user->password = bcrypt($input['password']);
180+
$user->password = Hash::make($input['password']);
179181

180182
if ($user->save()) {
181183
event(new UserPasswordChanged($user));
@@ -323,15 +325,19 @@ public function mark($user, $status)
323325
* @param $user
324326
*
325327
* @throws GeneralException
328+
*
329+
* @return null
326330
*/
327-
protected function checkUserByEmail($input, $user)
331+
protected function checkUserByEmail($input, $user = null)
328332
{
329333
//Figure out if email is not the same
330-
if ($user->email != $input['email']) {
331-
//Check to see if email exists
332-
if ($this->query()->where('email', '=', $input['email'])->first()) {
333-
throw new GeneralException(trans('exceptions.backend.access.users.email_error'));
334-
}
334+
if ($user && $user->email === $input['email']) {
335+
return;
336+
}
337+
338+
//Check to see if email exists
339+
if ($this->query()->where('email', '=', $input['email'])->withTrashed()->exists()) {
340+
throw new GeneralException(trans('exceptions.backend.access.users.email_error'));
335341
}
336342
}
337343

@@ -387,7 +393,7 @@ protected function createUserStub($input)
387393
$user->first_name = $input['first_name'];
388394
$user->last_name = $input['last_name'];
389395
$user->email = $input['email'];
390-
$user->password = bcrypt($input['password']);
396+
$user->password = Hash::make($input['password']);
391397
$user->status = isset($input['status']) ? 1 : 0;
392398
$user->confirmation_code = md5(uniqid(mt_rand(), true));
393399
$user->confirmed = isset($input['confirmed']) ? 1 : 0;

app/Repositories/Frontend/Access/User/UserRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function create(array $data, $provider = false)
9696
$user->email = $data['email'];
9797
$user->confirmation_code = md5(uniqid(mt_rand(), true));
9898
$user->status = 1;
99-
$user->password = $provider ? null : bcrypt($data['password']);
99+
$user->password = $provider ? null : Hash::make($data['password']);
100100
$user->is_term_accept = $data['is_term_accept'];
101101

102102
// If users require approval, confirmed is false regardless of account type
@@ -284,7 +284,7 @@ public function changePassword($input)
284284
$user = $this->find(access()->id());
285285

286286
if (Hash::check($input['old_password'], $user->password)) {
287-
$user->password = bcrypt($input['password']);
287+
$user->password = Hash::make($input['password']);
288288

289289
if ($user->save()) {
290290
$user->notify(new UserChangedPassword($input['password']));

client/build/client-modules.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer.json

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,23 @@
3131
},
3232
"require-dev": {
3333
"bvipul/generator": "^5.8.1",
34-
"codedungeon/phpunit-result-printer": "^0.19.10",
35-
"filp/whoops": "~2.0",
36-
"friendsofphp/php-cs-fixer": "^2.10",
37-
"fzaninotto/faker": "~1.4",
34+
"codedungeon/phpunit-result-printer": "^0.26.1",
35+
"filp/whoops": "^2.0",
36+
"friendsofphp/php-cs-fixer": "^2.14",
37+
"fzaninotto/faker": "^1.4",
3838
"laravel/telescope": "^2.0",
39-
"mockery/mockery": "1.2.2",
40-
"nunomaduro/larastan": "^0.3.15",
41-
"phpunit/phpunit": "~7.0",
42-
"xethron/migrations-generator": "2.0.2"
39+
"mockery/mockery": "^1.0",
40+
"phpunit/phpunit": "^8.0"
41+
},
42+
"config": {
43+
"optimize-autoloader": true,
44+
"preferred-install": "dist",
45+
"sort-packages": true
4346
},
4447
"autoload": {
4548
"classmap": [
4649
"database/seeds",
47-
"database/factories",
48-
"database"
50+
"database/factories"
4951
],
5052
"psr-4": {
5153
"App\\": "app/"
@@ -65,17 +67,24 @@
6567
"tests/Utilities/helpers.php"
6668
]
6769
},
70+
"extra": {
71+
"laravel": {
72+
"dont-discover": []
73+
}
74+
},
75+
"minimum-stability": "dev",
76+
"prefer-stable": true,
6877
"scripts": {
78+
"post-autoload-dump": [
79+
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
80+
"@php artisan package:discover --ansi"
81+
],
6982
"post-root-package-install": [
7083
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
7184
],
7285
"post-create-project-cmd": [
7386
"php artisan key:generate"
7487
],
75-
"post-autoload-dump": [
76-
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
77-
"@php artisan package:discover"
78-
],
7988
"clear-all": [
8089
"@php artisan clear-compiled",
8190
"@php artisan cache:clear",
@@ -99,11 +108,11 @@
99108
"./vendor/bin/php-cs-fixer fix resources/ --show-progress=estimating",
100109
"./vendor/bin/php-cs-fixer fix routes/ --show-progress=estimating",
101110
"./vendor/bin/php-cs-fixer fix tests/ --show-progress=estimating"
111+
],
112+
"self-diagnosis": [
113+
"@composer validate",
114+
"@php artisan self-diagnosis",
115+
"npm audit"
102116
]
103-
},
104-
"config": {
105-
"preferred-install": "dist",
106-
"sort-packages": true,
107-
"optimize-autoloader": true
108117
}
109118
}

0 commit comments

Comments
 (0)