Skip to content

Commit

Permalink
Merge pull request #305 from ControlPanel-gg/development
Browse files Browse the repository at this point in the history
Increased api limits
Re-sync bug
  • Loading branch information
AVMG20 authored Nov 18, 2021
2 parents 47037dc + 5103dad commit 3a67fa8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 25 deletions.
13 changes: 9 additions & 4 deletions app/Classes/Pterodactyl.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

class Pterodactyl
{
/**
* @description per_page option to pull more than the default 50 from pterodactyl
*/
public CONST PER_PAGE = 200;

//TODO: Extend error handling (maybe logger for more errors when debugging)

/**
Expand Down Expand Up @@ -43,7 +48,7 @@ private static function getException(): Exception
*/
public static function getEggs(Nest $nest)
{
$response = self::client()->get("/application/nests/{$nest->id}/eggs?include=nest,variables");
$response = self::client()->get("/application/nests/{$nest->id}/eggs?include=nest,variables&per_page=" . self::PER_PAGE);
if ($response->failed()) throw self::getException();
return $response->json()['data'];
}
Expand All @@ -54,7 +59,7 @@ public static function getEggs(Nest $nest)
*/
public static function getNodes()
{
$response = self::client()->get('/application/nodes');
$response = self::client()->get('/application/nodes?per_page=' . self::PER_PAGE);
if ($response->failed()) throw self::getException();
return $response->json()['data'];
}
Expand All @@ -65,7 +70,7 @@ public static function getNodes()
*/
public static function getNests()
{
$response = self::client()->get('/application/nests');
$response = self::client()->get('/application/nests?per_page=' . self::PER_PAGE);
if ($response->failed()) throw self::getException();
return $response->json()['data'];
}
Expand All @@ -76,7 +81,7 @@ public static function getNests()
*/
public static function getLocations()
{
$response = self::client()->get('/application/locations');
$response = self::client()->get('/application/locations?per_page=' . self::PER_PAGE);
if ($response->failed()) throw self::getException();
return $response->json()['data'];
}
Expand Down
8 changes: 5 additions & 3 deletions app/Http/Controllers/Auth/SocialiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Http\Controllers\Controller;
use App\Models\Configuration;
use App\Models\DiscordUser;
use App\Models\User;
use App\Models\Voucher;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Http;
Expand All @@ -27,22 +28,23 @@ public function callback()
return abort(500);
}

/** @var User $user */
$user = Auth::user();
$discord = Socialite::driver('discord')->user();
$discordUser = DiscordUser::find($discord->id);
$botToken = env('DISCORD_BOT_TOKEN');
$guildId = env('DISCORD_GUILD_ID');
$roleId = env('DISCORD_ROLE_ID');

//save / update discord_users
if (is_null($discordUser)) {
if (is_null($user->discordUser)) {
//create discord user in db
DiscordUser::create(array_merge($discord->user, ['user_id' => Auth::user()->id]));
//update user
Auth::user()->increment('credits', Configuration::getValueByKey('CREDITS_REWARD_AFTER_VERIFY_DISCORD'));
Auth::user()->increment('server_limit', Configuration::getValueByKey('SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD'));
Auth::user()->update(['discord_verified_at' => now()]);
} else {
$discordUser->update($discord->user);
$user->discordUser->update($discord->user);
}

//force user into discord server
Expand Down
44 changes: 26 additions & 18 deletions resources/views/profile/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@
class="pt-sm-2 pb-1 mb-0 text-nowrap">{{$user->name}}</h4>
<p class="mb-0">{{$user->email}}
@if($user->hasVerifiedEmail())
<i data-toggle="popover" data-trigger="hover" data-content="Verified" class="text-success fas fa-check-circle"></i>
<i data-toggle="popover" data-trigger="hover" data-content="Verified"
class="text-success fas fa-check-circle"></i>
@else
<i data-toggle="popover" data-trigger="hover" data-content="Not verified" class="text-danger fas fa-exclamation-circle"></i>
<i data-toggle="popover" data-trigger="hover"
data-content="Not verified"
class="text-danger fas fa-exclamation-circle"></i>
@endif

</p>
Expand Down Expand Up @@ -189,16 +192,17 @@ class="form-control @error('new_password_confirmation') is-invalid @enderror"
</div>
@if(!empty(env('DISCORD_CLIENT_ID')) && !empty(env('DISCORD_CLIENT_SECRET')))
<div class="col-12 col-sm-5 offset-sm-1 mb-3">
<b>Link your discord account!</b>
@if(is_null(Auth::user()->discordUser))
<b>Link your discord account!</b>
<div class="verify-discord">
<div class="mb-3">
@if($credits_reward_after_verify_discord)
<p>By verifying your discord account, you receive an
extra
<b><i
class="fa fa-coins mx-1"></i>{{$credits_reward_after_verify_discord}}
</b> {{CREDITS_DISPLAY_NAME}} and increased server limit
</b> {{CREDITS_DISPLAY_NAME}} and increased server
limit
</p>
@endif
</div>
Expand All @@ -213,21 +217,25 @@ class="fa fa-coins mx-1"></i>{{$credits_reward_after_verify_discord}}
<p>You are verified!</p>
</div>
</div>
<div class="row">
<div class="small-box bg-dark">
<div class="d-flex justify-content-between">
<div class="p-3">
<h3>{{$user->discordUser->username}} <sup>{{$user->discordUser->locale}}</sup> </h3>
<p>{{$user->discordUser->id}}
</p>
</div>
<div class="p-3"><img width="100px" height="100px" class="rounded-circle" src="{{$user->discordUser->getAvatar()}}" alt="avatar"></div>
</div>
<div class="small-box-footer">
<a href="{{route('auth.redirect')}}">
<i class="fab fa-discord mr-1"></i>Re-Sync Discord
</a>
<div class="row pl-2">
<div class="small-box bg-dark">
<div class="d-flex justify-content-between">
<div class="p-3">
<h3>{{$user->discordUser->username}}
<sup>{{$user->discordUser->locale}}</sup></h3>
<p>{{$user->discordUser->id}}
</p>
</div>
<div class="p-3"><img width="100px" height="100px"
class="rounded-circle"
src="{{$user->discordUser->getAvatar()}}"
alt="avatar"></div>
</div>
<div class="small-box-footer">
<a href="{{route('auth.redirect')}}">
<i class="fab fa-discord mr-1"></i>Re-Sync Discord
</a>
</div>
</div>
</div>
@endif
Expand Down

0 comments on commit 3a67fa8

Please sign in to comment.