Skip to content

Commit

Permalink
fix: Panel Inconsistencies and issues (#952)
Browse files Browse the repository at this point in the history
  • Loading branch information
1day2die authored Nov 11, 2024
2 parents 1a7e2c8 + 03c2cac commit c0b75bd
Show file tree
Hide file tree
Showing 44 changed files with 137 additions and 222 deletions.
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ DB_DATABASE=dashboard
DB_USERNAME=dashboarduser
DB_PASSWORD=

### --- Discord Settings (required for Discord OAuth) --- ###
DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=

### --- Discord Settings End --- ###

### --- Google Recaptcha Settings --- ###
RECAPTCHA_SITE_KEY=6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
RECAPTCHA_SECRET_KEY=6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe
### --- Google Recaptcha Settings End --- ###

# No-SQL
MEMCACHED_HOST=127.0.0.1

Expand All @@ -36,6 +47,7 @@ REDIS_PASSWORD=null
REDIS_PORT=6379
### --- Database Settings End --- ###


### --- Mail Server Settings --- ###
MAIL_MAILER=smtp
MAIL_HOST=mailhog
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ Homestead.yaml
public/install/logs.txt
install.lock
public/install/logs/installer.log

/.idea
cpggdatabase.sql
3 changes: 1 addition & 2 deletions app/Http/Controllers/Admin/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function update(Request $request)

$this->checkPermission("settings." . strtolower($category) . ".write");

$settings_class = request()->get('settings_class');
$settings_class = (string) request()->get('settings_class');

if (method_exists($settings_class, 'getValidations')) {
$validations = $settings_class::getValidations();
Expand All @@ -122,7 +122,6 @@ public function update(Request $request)
$rp = new \ReflectionProperty($settingsClass, $key);
$rpType = $rp->getType();


if ($rpType == 'bool') {
$settingsClass->$key = $request->has($key);
continue;
Expand Down
15 changes: 14 additions & 1 deletion app/Http/Controllers/TicketsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Str;
use App\Settings\GeneralSettings;

class TicketsController extends Controller
{
Expand All @@ -34,8 +36,13 @@ public function index(LocaleSettings $locale_settings, TicketSettings $ticketSet
]);
}


public function store(Request $request, GeneralSettings $generalSettings)
{
if (RateLimiter::tooManyAttempts('ticket-send:'.Auth::user()->id, $perMinute = 1)) {
return redirect()->back()->with('error', __('Please wait before creating a new Ticket'));
}

$validateData = [
'title' => 'required|string|max:255',
'ticketcategory' => 'required|numeric',
Expand All @@ -48,6 +55,7 @@ public function store(Request $request, GeneralSettings $generalSettings)
}

$this->validate($request, $validateData);

$ticket = new Ticket(
[
'title' => $request->input('title'),
Expand All @@ -70,6 +78,7 @@ public function store(Request $request, GeneralSettings $generalSettings)


$user->notify(new CreateNotification($ticket));
RateLimiter::hit('ticket-send:'.Auth::user()->id);

return redirect()->route('ticket.index')->with('success', __('A ticket has been opened, ID: #') . $ticket->ticket_id);
}
Expand All @@ -92,6 +101,9 @@ public function show($ticket_id, PterodactylSettings $ptero_settings)

public function reply(Request $request)
{
if (RateLimiter::tooManyAttempts('ticket-reply:'.Auth::user()->id, $perMinute = 1)) {
return redirect()->back()->with('error', __('Please wait before answering a Ticket'));
}
//check in blacklist
$check = TicketBlacklist::where('user_id', Auth::user()->id)->first();
if ($check && $check->status == 'True') {
Expand All @@ -104,6 +116,7 @@ public function reply(Request $request)
return redirect()->back()->with('warning', __('Ticket not found on the server. It potentially got deleted earlier'));
}
$ticket->status = 'Client Reply';
$ticket->updated_at = now();
$ticket->update();
$ticketcomment = TicketComment::create([
'ticket_id' => $request->input('ticket_id'),
Expand All @@ -118,7 +131,7 @@ public function reply(Request $request)
foreach($staffNotify as $staff){
Notification::send($staff, new AdminReplyNotification($ticket, $user, $newmessage));
}

RateLimiter::hit('ticket-reply:'.Auth::user()->id);
return redirect()->back()->with('success', __('Your comment has been submitted'));
}

Expand Down
15 changes: 14 additions & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\RateLimiter;
use Spatie\Activitylog\LogOptions;
use Spatie\Activitylog\Traits\CausesActivity;
use Spatie\Activitylog\Traits\LogsActivity;
Expand Down Expand Up @@ -188,7 +189,19 @@ public function discordUser()

public function sendEmailVerificationNotification()
{
$this->notify(new QueuedVerifyEmail);
// Rate limit the email verification notification to 1 attempt per 30 minutes
$executed = RateLimiter::attempt(
key: 'verify-mail'. $this->id,
maxAttempts: 1,
callback: function() {
$this->notify(new QueuedVerifyEmail);
},
decaySeconds: 1800
);

if (! $executed) {
return response()->json(['message' => 'Too many requests, try again in: ' . RateLimiter::availableIn('verify-mail:'. $this->id) . ' seconds'], 429);
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@
Route::get('ticket', [TicketsController::class, 'index'])->name('ticket.index');
Route::get('ticket/datatable', [TicketsController::class, 'datatable'])->name('ticket.datatable');
Route::get('ticket/new', [TicketsController::class, 'create'])->name('ticket.new');

Route::post('ticket/new', [TicketsController::class, 'store'])->middleware(['throttle:1,1'])->name('ticket.new.store');
Route::get('ticket/show/{ticket_id}', [TicketsController::class, 'show'])->name('ticket.show');
Route::post('ticket/reply', [TicketsController::class, 'reply'])->middleware(['throttle:10,1'])->name('ticket.reply');

Route::post('ticket/status/{ticket_id}', [TicketsController::class, 'changeStatus'])->name('ticket.changeStatus');


Expand Down
3 changes: 3 additions & 0 deletions themes/BlueInfinity/views/layouts/main.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class="mr-2 fab fa-discord"></i>{{ __('Discord') }}</a>
</button>
@endforeach

<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
</div>
</li>
Expand Down Expand Up @@ -190,6 +191,8 @@ class="dropdown-item dropdown-footer">{{ __('Mark all as read') }}</a>
<i class="mr-2 text-gray-400 fas fa-sign-out-alt fa-sm fa-fw"></i>
{{ __('Logout') }}
</button>

<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
</div>
</li>
Expand Down
2 changes: 2 additions & 0 deletions themes/default/views/admin/activitylogs/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
<button class="btn btn-light btn-sm" type="submit"><i class="fa fa-search"></i></button>
</div>
</div>

<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions themes/default/views/admin/api/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class="form-control @error('memo') is-invalid @enderror">
{{__('Submit')}}
</button>
</div>

<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions themes/default/views/admin/api/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class="form-control @error('memo') is-invalid @enderror">
{{__('Submit')}}
</button>
</div>

<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions themes/default/views/admin/coupons/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ class="input-group-append"
{{__('Submit')}}
</button>
</div>

<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions themes/default/views/admin/coupons/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ class="input-group-append"
{{__('Submit')}}
</button>
</div>

<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions themes/default/views/admin/legal/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class="form-control @error('imprint') is-invalid @enderror">
<div class="row">
<button class="btn btn-primary ml-3 mt-3">{{ __('Save') }}</button>
</div>

<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
</div>
<!-- END CUSTOM CONTENT -->
Expand Down
100 changes: 0 additions & 100 deletions themes/default/views/admin/nests/index.blade.php

This file was deleted.

Loading

0 comments on commit c0b75bd

Please sign in to comment.