Skip to content

Commit

Permalink
Merge pull request #417 from viralsolani/develop
Browse files Browse the repository at this point in the history
Bug Fixes
  • Loading branch information
viralsolani authored Jul 9, 2019
2 parents c9cdb00 + df398ec commit 3f6dae1
Show file tree
Hide file tree
Showing 16 changed files with 783 additions and 481 deletions.
40 changes: 22 additions & 18 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
APP_NAME="Laravel Admin Panel"
APP_SHORT_NAME="LAP"
APP_DEMO=false
APP_NAME="Laravel 5.8 AdminPanel"
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_LOG_LEVEL=debug
DEBUGBAR_ENABLED=false
APP_URL=http://localhost

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_LOCALE_PHP=en_US
APP_TIMEZONE=UTC
LOG_CHANNEL=daily
SINGLE_LOGIN=false

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
Expand All @@ -14,34 +19,33 @@ DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

# Access
ENABLE_REGISTRATION=true
REQUIRES_APPROVAL=false

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync

#Session Timeout
SESSION_TIMEOUT_STATUS=true
#In Seconds
SESSION_TIMEOUT=600
SESSION_ENCRYPT=false
QUEUE_CONNECTION=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_FROM=[email protected]
MAIL_FROM_NAME=Admin
MAIL_HOST=localhost
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
2 changes: 1 addition & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function render($request, Exception $exception)
*/
if ($exception instanceof UnauthorizedHttpException) {
switch (get_class($exception->getPrevious())) {
case \App\Exceptions\Handler::class:
case self::class:
return $this->setStatusCode($exception->getStatusCode())->respondWithError('Token has not been provided.');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class UpdateUserPasswordRequest extends Request
*/
public function authorize()
{
return access()->allow('edit-user');
return true;
}

/**
Expand Down
12 changes: 0 additions & 12 deletions app/Models/Access/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,6 @@ public function getJWTIdentifier()
return $this->getKey();
}

/**
* Set password attribute.
*
* @param [string] $password
*/
public function setPasswordAttribute($password)
{
if (!empty($password)) {
$this->attributes['password'] = bcrypt($password);
}
}

/**
* Return a key value array, containing any custom claims to be added to the JWT.
*
Expand Down
22 changes: 14 additions & 8 deletions app/Repositories/Backend/Access/User/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public function create($request)
$permissions = $request->get('permissions');
$user = $this->createUserStub($data);

$this->checkUserByEmail($data, $user);

DB::transaction(function () use ($user, $data, $roles, $permissions) {
if ($user->save()) {

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

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

if ($user->save()) {
event(new UserPasswordChanged($user));
Expand Down Expand Up @@ -323,15 +325,19 @@ public function mark($user, $status)
* @param $user
*
* @throws GeneralException
*
* @return null
*/
protected function checkUserByEmail($input, $user)
protected function checkUserByEmail($input, $user = null)
{
//Figure out if email is not the same
if ($user->email != $input['email']) {
//Check to see if email exists
if ($this->query()->where('email', '=', $input['email'])->first()) {
throw new GeneralException(trans('exceptions.backend.access.users.email_error'));
}
if ($user && $user->email === $input['email']) {
return;
}

//Check to see if email exists
if ($this->query()->where('email', '=', $input['email'])->withTrashed()->exists()) {
throw new GeneralException(trans('exceptions.backend.access.users.email_error'));
}
}

Expand Down Expand Up @@ -387,7 +393,7 @@ protected function createUserStub($input)
$user->first_name = $input['first_name'];
$user->last_name = $input['last_name'];
$user->email = $input['email'];
$user->password = bcrypt($input['password']);
$user->password = Hash::make($input['password']);
$user->status = isset($input['status']) ? 1 : 0;
$user->confirmation_code = md5(uniqid(mt_rand(), true));
$user->confirmed = isset($input['confirmed']) ? 1 : 0;
Expand Down
4 changes: 2 additions & 2 deletions app/Repositories/Frontend/Access/User/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function create(array $data, $provider = false)
$user->email = $data['email'];
$user->confirmation_code = md5(uniqid(mt_rand(), true));
$user->status = 1;
$user->password = $provider ? null : bcrypt($data['password']);
$user->password = $provider ? null : Hash::make($data['password']);
$user->is_term_accept = $data['is_term_accept'];

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

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

if ($user->save()) {
$user->notify(new UserChangedPassword($input['password']));
Expand Down
2 changes: 1 addition & 1 deletion client/build/client-modules.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 28 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,23 @@
},
"require-dev": {
"bvipul/generator": "^5.8.1",
"codedungeon/phpunit-result-printer": "^0.19.10",
"filp/whoops": "~2.0",
"friendsofphp/php-cs-fixer": "^2.10",
"fzaninotto/faker": "~1.4",
"codedungeon/phpunit-result-printer": "^0.26.1",
"filp/whoops": "^2.0",
"friendsofphp/php-cs-fixer": "^2.14",
"fzaninotto/faker": "^1.4",
"laravel/telescope": "^2.0",
"mockery/mockery": "1.2.2",
"nunomaduro/larastan": "^0.3.15",
"phpunit/phpunit": "~7.0",
"xethron/migrations-generator": "2.0.2"
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^8.0"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories",
"database"
"database/factories"
],
"psr-4": {
"App\\": "app/"
Expand All @@ -65,17 +67,24 @@
"tests/Utilities/helpers.php"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
],
"clear-all": [
"@php artisan clear-compiled",
"@php artisan cache:clear",
Expand All @@ -99,11 +108,11 @@
"./vendor/bin/php-cs-fixer fix resources/ --show-progress=estimating",
"./vendor/bin/php-cs-fixer fix routes/ --show-progress=estimating",
"./vendor/bin/php-cs-fixer fix tests/ --show-progress=estimating"
],
"self-diagnosis": [
"@composer validate",
"@php artisan self-diagnosis",
"npm audit"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
Loading

0 comments on commit 3f6dae1

Please sign in to comment.