Skip to content

Commit

Permalink
Update camouflage, add isBot on user visitors, add socialite default …
Browse files Browse the repository at this point in the history
…role
  • Loading branch information
ajifatur committed Aug 19, 2024
1 parent cdb33dd commit 62a1d97
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 9 deletions.
4 changes: 3 additions & 1 deletion resources/views/admin/log/activity.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<th width="80">Route</th>
<th width="70">Method</th>
<th width="80">IP Address</th>
<th width="40">Is Bot?</th>
</tr>
</thead>
<tbody></tbody>
Expand Down Expand Up @@ -73,7 +74,8 @@
{data: 'url', name: 'url'},
{data: 'route', name: 'route'},
{data: 'method', name: 'method'},
{data: 'ip', name: 'ip'}
{data: 'ip', name: 'ip'},
{data: 'is_bot', name: 'is_bot'},
],
order: [1, 'desc']
});
Expand Down
16 changes: 16 additions & 0 deletions resources/views/admin/setting/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,22 @@
@endif
</div>
</div>
<div class="row mb-3">
<label class="col-lg-3 col-md-4 col-form-label">
Default Role Socialite<span class="text-danger">*</span><br><code>setting('socialite_default_role')</code>
</label>
<div class="col-lg-9 col-md-8">
@foreach($roles as $role)
<div class="form-check">
<input class="form-check-input" type="radio" name="setting[socialite_default_role]" id="socialite_default_role-{{ $role->id }}" value="{{ $role->code }}" {{ setting('socialite_default_role') == $role->code ? 'checked' : '' }}>
<label class="form-check-label" for="socialite_default_role-{{ $role->id }}">{{ $role->name }}</label>
</div>
@endforeach
@if($errors->has('setting.socialite_default_role'))
<div class="small text-danger">{{ $errors->first('setting.socialite_default_role') }}</div>
@endif
</div>
</div>
<div class="row mb-3">
<label class="col-lg-3 col-md-4 col-form-label">
Akun Tidak Terdaftar Bisa Login<span class="text-danger">*</span><br><code>setting('allow_unregistered_account')</code>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/admin/user/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<td><span class="badge {{ $user->status == 1 ? 'bg-success' : 'bg-danger' }}">{{ status($user->status) }}</span></td>
<td align="center">
<div class="btn-group">
@if(session()->exists('user') && (session('user') != $user->id && Auth::user()->id != $user->id))
@if(((session()->exists('user') && session('user') != $user->id) || session()->exists('user') == false) && Auth::user()->id != $user->id)
<a href="#" class="btn btn-sm btn-info btn-camouflage" data-id="{{ $user->id }}" data-bs-toggle="tooltip" title="Kamuflase"><i class="bi-person-x"></i></a>
@endif
<a href="{{ route('admin.user.edit', ['id' => $user->id]) }}" class="btn btn-sm btn-warning" data-bs-toggle="tooltip" title="Edit"><i class="bi-pencil"></i></a>
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/Auth/#Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class LoginController extends \App\Http\Controllers\Controller
*
* @var string
*/
protected $role = 'admin';
// protected $role = 'admin';

/**
* Show login form.
Expand Down Expand Up @@ -239,7 +239,7 @@ public function findOrCreateUser($user, $provider)
if(!$data) {
// Save the user
$data = new User;
$data->role_id = role($this->role);
$data->role_id = role(setting('socialite_default_role'));
$data->name = $user->getName();
$data->username = $user->getNickname() != null ? $user->getNickname() : $user->getEmail();
$data->email = $user->getEmail();
Expand Down
7 changes: 6 additions & 1 deletion src/Http/Controllers/LogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ public function activity(Request $request)
{{ $method }}
@endif
')
->rawColumns(['user', 'datetime', 'url', 'route', 'method'])
->editColumn('is_bot', '
@if(isset($is_bot) && $is_bot == true)
Ya
@endif
')
->rawColumns(['user', 'datetime', 'url', 'route', 'method', 'is_bot'])
->make(true);
}

Expand Down
9 changes: 7 additions & 2 deletions src/Http/Controllers/SettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Validator;
use Ajifatur\Helpers\FileExt;
use Ajifatur\FaturHelper\Models\Role;
use Ajifatur\FaturHelper\Models\Setting;

class SettingController extends \App\Http\Controllers\Controller
Expand All @@ -19,15 +20,19 @@ class SettingController extends \App\Http\Controllers\Controller
*/
public function index(Request $request)
{
// // Check the access
// Check the access
has_access(__METHOD__, Auth::user()->role_id);

// Get roles
$roles = Role::orderBy('num_order','asc')->get();

// Get timezones
$timezones = timezone_identifiers_list(2047);

// View
return view('faturhelper::admin/setting/index', [
'timezones' => $timezones
'roles' => $roles,
'timezones' => $timezones,
]);
}

Expand Down
4 changes: 3 additions & 1 deletion src/Http/Middleware/Logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Route;
use hisorange\BrowserDetect\Parser as Browser;
use Ajifatur\FaturHelper\Models\User;

class Logs
Expand Down Expand Up @@ -40,7 +41,8 @@ public function handle($request, Closure $next, $guard = null)
'ajax' => $request->ajax(),
'ip' => $request->ip(),
'route' => Route::currentRouteName(),
'route_params' => $request->query()
'route_params' => $request->query(),
'is_bot' => Browser::isBot()
])
);

Expand Down
3 changes: 2 additions & 1 deletion src/Seeders/Dummy/RoleSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class RoleSeeder extends Seeder
public function run()
{
$roles = [
['code' => 'super-admin', 'name' => 'Super Admin', 'is_admin' => 1, 'is_global' => 1, 'num_order' => 1]
['code' => 'super-admin', 'name' => 'Super Admin', 'is_admin' => 1, 'is_global' => 1, 'num_order' => 1],
['code' => 'member', 'name' => 'Member', 'is_admin' => 0, 'is_global' => 0, 'num_order' => 2],
];

foreach($roles as $role) {
Expand Down
1 change: 1 addition & 0 deletions src/Seeders/SettingSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function run()
['code' => 'allow_login_by_email', 'content' => '0'],
['code' => 'non_admin_can_login', 'content' => '0'],
['code' => 'socialite', 'content' => '0'],
['code' => 'socialite_default_role', 'content' => 'member'],
['code' => 'allow_unregistered_account', 'content' => '0'],
['code' => 'font_family', 'content' => 'default'],
];
Expand Down

0 comments on commit 62a1d97

Please # to comment.