Skip to content

Commit

Permalink
New setting module version&other improvements
Browse files Browse the repository at this point in the history
- Use setting 2.0 version
- Some code formatting
- Remove unnecessary folders
  • Loading branch information
dmitrijsmihailovs committed Feb 28, 2018
1 parent 7cddb35 commit f53c7cc
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 41 deletions.
Empty file removed Console/.gitkeep
Empty file.
Empty file removed Emails/.gitkeep
Empty file.
Empty file removed Events/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions Http/Controllers/Admin/PermissionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class PermissionsController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
Expand Down
1 change: 1 addition & 0 deletions Http/Controllers/Admin/RolesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class RolesController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
Expand Down
4 changes: 1 addition & 3 deletions Http/Controllers/Admin/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ public function __construct()

$this->config = array_merge($this->config, $fromConfig);

$this->model = app(
config('auth.providers.users.model')
);
$this->model = app(config('auth.providers.users.model'));
}

/**
Expand Down
Empty file removed Jobs/.gitkeep
Empty file.
Empty file removed Listeners/.gitkeep
Empty file.
3 changes: 2 additions & 1 deletion Models/UserOauthIdentity.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class UserOauthIdentity extends Model

/**
* UserOauthIdentity constructor.
*
* @param array $attributes
*/
public function __construct($attributes = [])
Expand Down Expand Up @@ -80,4 +81,4 @@ public function setLastLoginTime()
'last_login_at' => Carbon::now()
]);
}
}
}
Empty file removed Notifications/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion Traits/AdminUsersPagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private function modifyDatatableColumns(&$datatable, $presenter)
foreach ($this->getDatatableColumns() as $name => $title) {
$method = camel_case($name);

if (! method_exists($presenter, $method)) {
if (!method_exists($presenter, $method)) {
continue;
}

Expand Down
29 changes: 8 additions & 21 deletions Traits/ControllerSocialite.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ protected function getProviders()
{
$providers = [];

foreach(config('netcore.module-user.socialite-providers') as $provider => $state) {
if($state) {
foreach (config('netcore.module-user.socialite-providers') as $provider => $state) {
if ($state) {
$providers[] = $provider;
}
}
Expand All @@ -38,8 +38,6 @@ public function providerRedirect(string $provider)
return Socialite::driver($provider)->redirect();
}



/**
* Check for provider existence
*
Expand All @@ -53,25 +51,16 @@ private function providerGate(string $provider)
}

// Set redirect URL on the fly (must be absolute)
config()->set(
'services.' . $provider . '.client_id',
setting()->get($provider . '_client_id')
);
config()->set(
'services.' . $provider . '.client_secret',
setting()->get($provider . '_client_secret')
);
config()->set(
'services.' . $provider . '.redirect',
url('/login/' . $provider . '/callback')
);
config()->set('services.' . $provider . '.client_id', setting()->get('oauth.' . $provider . '_client_id'));
config()->set('services.' . $provider . '.client_secret', setting()->get('oauth.' . $provider . '_client_secret'));
config()->set('services.' . $provider . '.redirect', url('/login/' . $provider . '/callback'));
}

/**
* Bad response handler
*
* @param Exception $exception
* @param string $provider
* @param string $provider
* @return \Illuminate\Http\RedirectResponse
*/
private function handleBadProviderResponse(Exception $exception, string $provider)
Expand All @@ -81,9 +70,7 @@ private function handleBadProviderResponse(Exception $exception, string $provide
if ($attempts > 5) {
session()->forget($provider . '-attempts');

return redirect()->route('login')->withErrors(
trans('login.unexpected_provider_error')
);
return redirect()->route('login')->withErrors(trans('login.unexpected_provider_error'));
}

$attempts++;
Expand All @@ -93,4 +80,4 @@ private function handleBadProviderResponse(Exception $exception, string $provide
return $this->providerRedirect($provider);
}

}
}
5 changes: 3 additions & 2 deletions Traits/ModuleUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Modules\User\Traits;

trait ModuleUser {
trait ModuleUser
{

/**
* Set "fullName" attribute on model
Expand All @@ -25,4 +26,4 @@ public function gravatar($size = 90)
return '//www.gravatar.com/avatar/' . md5($this->email) . '?s=' . $size . '&d=mm';
}

}
}
15 changes: 8 additions & 7 deletions Traits/ReplaceableAttributes.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

namespace Modules\User\Traits;

trait ReplaceableAttributes {
trait ReplaceableAttributes
{

/**
* Returns replaceable data
Expand All @@ -10,16 +12,15 @@ trait ReplaceableAttributes {
*/
public function getReplaceable(): array
{
$attributes = $this->replaceable ?? [];
$prefix = $this->replaceablePrefix ?? '';
$replaceable = [];
$attributes = $this->replaceable ?? [];
$prefix = $this->replaceablePrefix ?? '';
$replaceable = [];

foreach ($attributes as $attribute)
{
foreach ($attributes as $attribute) {
$replaceable[strtoupper($prefix . $attribute)] = $this[$attribute] ?? null;
}

return $replaceable;
}

}
8 changes: 3 additions & 5 deletions Traits/UserPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function role()
{
$module = Module::find('Permission');

if (! $module || !$module->enabled()) {
if (!$module || !$module->enabled()) {
return (object)[
'levels' => collect()
];
Expand All @@ -34,8 +34,6 @@ public function isAdmin()
}

/**
*
*
* @param Request $request
* @return bool
* @internal param $name
Expand All @@ -61,7 +59,7 @@ public function hasPermission(Request $request): bool
if (!$levels->count() && !$user->isAdmin()) {
return false;
}

foreach ($levels as $level) {
foreach ($level->routes as $route) {
if ($route->route) {
Expand Down Expand Up @@ -89,4 +87,4 @@ public function hasPermission(Request $request): bool

return false;
}
}
}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"require": {
"php": ">=7.0",
"yajra/laravel-datatables-oracle": "~8.0",
"maatwebsite/excel": "~2.1.0"
"maatwebsite/excel": "~2.1.0",
"netcore/module-setting": "^2.0"
},
"minimum-stability": "dev"
}

0 comments on commit f53c7cc

Please sign in to comment.