From d79ca410334d856fd822b7c94367a10d171a167d Mon Sep 17 00:00:00 2001 From: 1day2die Date: Sun, 26 Dec 2021 23:37:16 +0100 Subject: [PATCH 01/12] fix --- app/Http/Controllers/Auth/RegisterController.php | 5 ++++- resources/views/auth/register.blade.php | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 4073adef..b250ec8c 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -12,6 +12,7 @@ use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; use Illuminate\Support\Str; +use Illuminate\Validation\ValidationException; class RegisterController extends Controller { @@ -108,13 +109,15 @@ class RegisterController extends Controller if ($response->failed()) { $user->delete(); - return $user; + throw ValidationException::withMessages([__('Account already exists on Pterodactyl. Please contact the Support!')]); } $user->update([ 'pterodactyl_id' => $response->json()['attributes']['id'] ]); + + return $user; } } diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index ad4e4d70..0b18631f 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -23,6 +23,12 @@ {{ $message }} @enderror + @foreach ($errors->all() as $error) + + {!! $errors->first() !!} + + + @endforeach @csrf
From 7b974c17d2ead05362c03600359baf9afdafe35f Mon Sep 17 00:00:00 2001 From: 1day2die Date: Sun, 26 Dec 2021 23:45:40 +0100 Subject: [PATCH 02/12] Fixed errors appearing multiple times --- app/Http/Controllers/Auth/RegisterController.php | 4 +++- resources/views/auth/register.blade.php | 13 +++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index b250ec8c..23362785 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -109,7 +109,9 @@ class RegisterController extends Controller if ($response->failed()) { $user->delete(); - throw ValidationException::withMessages([__('Account already exists on Pterodactyl. Please contact the Support!')]); + throw ValidationException::withMessages([ + 'ptero' => [__('Account already exists on Pterodactyl. Please contact the Support!')], + ]); } $user->update([ diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index 0b18631f..dcf0683b 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -23,12 +23,13 @@ {{ $message }} @enderror - @foreach ($errors->all() as $error) - - {!! $errors->first() !!} - - - @endforeach + @if( $errors->has('ptero') ) + @foreach( $errors->get('ptero') as $err ) + + {{ $err }} + + @endforeach + @endif @csrf
From c1ca96d67ccdc6746dfaee84208a6b62c218b600 Mon Sep 17 00:00:00 2001 From: Dennis Date: Mon, 27 Dec 2021 07:58:46 +0100 Subject: [PATCH 03/12] Update RegisterController.php --- app/Http/Controllers/Auth/RegisterController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 23362785..58034a42 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -110,7 +110,7 @@ class RegisterController extends Controller if ($response->failed()) { $user->delete(); throw ValidationException::withMessages([ - 'ptero' => [__('Account already exists on Pterodactyl. Please contact the Support!')], + 'ptero_registration_error' => [__('Account already exists on Pterodactyl. Please contact the Support!')], ]); } From 5f57b4d784ce50ce793e4ca5337f10a62b951f6e Mon Sep 17 00:00:00 2001 From: Dennis Date: Mon, 27 Dec 2021 07:59:00 +0100 Subject: [PATCH 04/12] Update register.blade.php --- resources/views/auth/register.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index dcf0683b..30396d5e 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -23,8 +23,8 @@ {{ $message }} @enderror - @if( $errors->has('ptero') ) - @foreach( $errors->get('ptero') as $err ) + @if( $errors->has('ptero_registration_error') ) + @foreach( $errors->get('ptero_registration_error') as $err ) {{ $err }} From 8a583424db3116bcc4f443c35c6cf039ed6d5d70 Mon Sep 17 00:00:00 2001 From: 1Day Date: Mon, 27 Dec 2021 08:39:50 +0100 Subject: [PATCH 05/12] Fix --- app/Http/Controllers/ProfileController.php | 35 ++++++++++++++++ resources/views/profile/index.blade.php | 47 +++++++++++++++++----- 2 files changed, 72 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 3ddc1655..50f19d1e 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Classes\Pterodactyl; use App\Models\Configuration; use App\Models\User; use Illuminate\Contracts\View\Factory; @@ -11,6 +12,7 @@ use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; +use Illuminate\Validation\ValidationException; class ProfileController extends Controller { @@ -53,10 +55,27 @@ class ProfileController extends Controller 'new_password_confirmation' => 'required|same:new_password' ]); + //Update Users Password on Pterodactyl + //Username,Mail,First and Lastname are required aswell + $response = Pterodactyl::client()->patch('/application/users/'.$user->pterodactyl_id, [ + "password" => $request->input('new_password'), + "username" => $request->input('name'), + "first_name" => $request->input('name'), + "last_name" => $request->input('name'), + "email" => $request->input('email'), + + ]); + if ($response->failed()) { + throw ValidationException::withMessages([ + 'pterodactyl_error_message' => $response->toException()->getMessage(), + 'pterodactyl_error_status' => $response->toException()->getCode() + ]); + } //update password $user->update([ 'password' => Hash::make($request->input('new_password')), ]); + } //validate request @@ -80,11 +99,27 @@ class ProfileController extends Controller ]); } + //update name and email on Pterodactyl + $response = Pterodactyl::client()->patch('/application/users/'.$user->pterodactyl_id, [ + "username" => $request->input('name'), + "first_name" => $request->input('name'), + "last_name" => $request->input('name'), + "email" => $request->input('email'), + ]); + + if ($response->failed()) { + throw ValidationException::withMessages([ + 'pterodactyl_error_message' => $response->toException()->getMessage(), + 'pterodactyl_error_status' => $response->toException()->getCode() + ]); + } + //update name and email $user->update([ 'name' => $request->input('name'), 'email' => $request->input('email'), ]); + $user->sendEmailVerificationNotification(); return redirect()->route('profile.index')->with('success' , __('Profile updated')); } diff --git a/resources/views/profile/index.blade.php b/resources/views/profile/index.blade.php index 3a02f5b8..3bc69bca 100644 --- a/resources/views/profile/index.blade.php +++ b/resources/views/profile/index.blade.php @@ -11,7 +11,8 @@ @@ -28,9 +29,12 @@
@if(!Auth::user()->hasVerifiedEmail() && strtolower($force_email_verification) == 'true')
-
{{__('Required Email verification!')}}
+
{{__('Required Email verification!')}} +
{{__('You have not yet verified your email address')}} - {{__('Click here to resend verification email')}}
+ {{__('Click here to resend verification email')}} +
{{__('Please contact support If you didnt receive your verification email.')}}
@endif @@ -38,14 +42,19 @@ @if(is_null(Auth::user()->discordUser) && strtolower($force_discord_verification) == 'true') @if(!empty(env('DISCORD_CLIENT_ID')) && !empty(env('DISCORD_CLIENT_SECRET')))
-
{{__('Required Discord verification!')}}
+
+ {{__('Required Discord verification!')}} +
{{__('You have not yet verified your discord account')}} - {{__('Login with discord')}}
+ {{__('Login with discord')}}
{{__('Please contact support If you face any issues.')}}
@else
-
{{__('Required Discord verification!')}}
+
+ {{__('Required Discord verification!')}} +
{{__('Due to system settings you are required to verify your discord account!')}}
{{__('It looks like this hasnt been set-up correctly! Please contact support.')}}'
@@ -99,7 +108,8 @@
@@ -108,6 +118,20 @@
+ @if( $errors->has('pterodactyl_error_message') ) + @foreach( $errors->get('pterodactyl_error_message') as $err ) + + {{ $err }} + + @endforeach + @endif + @if( $errors->has('pterodactyl_error_status') ) + @foreach( $errors->get('pterodactyl_error_status') as $err ) + + {{ $err }} + + @endforeach + @endif
{{__('Change Password')}}
-
+ @@ -173,7 +198,8 @@
-
+
+
- +
From b72009aa840cc64b6e6104f5686f8eeb6d200b05 Mon Sep 17 00:00:00 2001 From: 1Day Date: Mon, 27 Dec 2021 09:10:38 +0100 Subject: [PATCH 06/12] Added API Route --- app/Http/Controllers/Api/UserController.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index 07a7a698..e5fbd571 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -88,9 +88,24 @@ class UserController extends Controller "role" => ['sometimes', Rule::in(['admin', 'mod', 'client', 'member'])], ]); - $user->update($request->all()); - event(new UserUpdateCreditsEvent($user)); + + //Update Users Password on Pterodactyl + //Username,Mail,First and Lastname are required aswell + $response = Pterodactyl::client()->patch('/application/users/'.$user->pterodactyl_id, [ + "username" => $request->name, + "first_name" => $request->name, + "last_name" => $request->name, + "email" => $request->email, + + ]); + if ($response->failed()) { + throw ValidationException::withMessages([ + 'pterodactyl_error_message' => $response->toException()->getMessage(), + 'pterodactyl_error_status' => $response->toException()->getCode() + ]); + } + $user->update($request->all()); return $user; } From 9a54ab67e12133a5d37182f279fc81e070bf6799 Mon Sep 17 00:00:00 2001 From: IceToast Date: Wed, 29 Dec 2021 16:04:44 +0100 Subject: [PATCH 07/12] =?UTF-8?q?fix:=20=F0=9F=90=9B=20remove=20whitespace?= =?UTF-8?q?s=20before=20request=20of=20stripe=20payment=5Fmethods=20list?= =?UTF-8?q?=20in=20.env?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Admin/PaymentController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Admin/PaymentController.php b/app/Http/Controllers/Admin/PaymentController.php index ea7d3dd0..b7d7b193 100644 --- a/app/Http/Controllers/Admin/PaymentController.php +++ b/app/Http/Controllers/Admin/PaymentController.php @@ -266,7 +266,7 @@ class PaymentController extends Controller ], 'mode' => 'payment', - "payment_method_types" => str_getcsv(env('STRIPE_METHODS')), + "payment_method_types" => str_getcsv(str_replace(' ', '', env('STRIPE_METHODS'))), 'success_url' => route('payment.StripeSuccess', ['product' => $creditProduct->id]) . '&session_id={CHECKOUT_SESSION_ID}', 'cancel_url' => route('payment.Cancel'), ]); @@ -522,7 +522,7 @@ class PaymentController extends Controller ->pricePerUnit($creditProduct->price); $notes = [ - __("Payment method") .": ". $payment->payment_method, + __("Payment method") . ": " . $payment->payment_method, ]; $notes = implode("
", $notes); From b831bd0c229f9b58fc37e99c96c1cd2fa4fadda6 Mon Sep 17 00:00:00 2001 From: Johannes F Date: Mon, 3 Jan 2022 22:14:45 +0100 Subject: [PATCH 08/12] =?UTF-8?q?feat:=20=E2=9C=A8=20Add=20api=20routes=20?= =?UTF-8?q?for=20suspending=20and=20unsuspending=20an=20User?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adresses #359 --- app/Http/Controllers/Api/UserController.php | 49 ++++++++++++++++++++- routes/api.php | 2 + 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index 17acd4b0..c2ad37f0 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -89,7 +89,7 @@ class UserController extends Controller ]); event(new UserUpdateCreditsEvent($user)); - + //Update Users Password on Pterodactyl //Username,Mail,First and Lastname are required aswell $response = Pterodactyl::client()->patch('/application/users/'.$user->pterodactyl_id, [ @@ -181,6 +181,53 @@ class UserController extends Controller return $user; } + /** + * Suspends the user + * + * @param Request $request + * @param int $id + * @return bool + * @throws ValidationException + */ + public function suspend(Request $request, int $id) + { + $discordUser = DiscordUser::find($id); + $user = $discordUser ? $discordUser->user : User::findOrFail($id); + + if ($user->isSuspended()) { + throw ValidationException::withMessages([ + 'error' => 'The user is already suspended', + ]); + } + $user->suspend(); + + return $user; + } + + /** + * Suspends the user + * + * @param Request $request + * @param int $id + * @return bool + * @throws ValidationException + */ + public function unsuspend(Request $request, int $id) + { + $discordUser = DiscordUser::find($id); + $user = $discordUser ? $discordUser->user : User::findOrFail($id); + + if (!$user->isSuspended()) { + throw ValidationException::withMessages([ + 'error' => "You cannot unsuspend an User who is not suspended." + ]); + } + + $user->unSuspend(); + + return $user; + } + /** * @throws ValidationException */ diff --git a/routes/api.php b/routes/api.php index bf9bc7d0..0de04de6 100644 --- a/routes/api.php +++ b/routes/api.php @@ -20,6 +20,8 @@ use Illuminate\Support\Facades\Route; Route::middleware('api.token')->group(function () { Route::patch('/users/{user}/increment', [UserController::class, 'increment']); Route::patch('/users/{user}/decrement', [UserController::class, 'decrement']); + Route::patch('/users/{user}/suspend', [UserController::class, 'suspend']); + Route::patch('/users/{user}/unsuspend', [UserController::class, 'unsuspend']); Route::resource('users', UserController::class)->except(['create']); Route::patch('/servers/{server}/suspend', [ServerController::class, 'suspend']); From 035be9f20162518aea6e2ff99b9facf82c5596fb Mon Sep 17 00:00:00 2001 From: IceToast Date: Tue, 4 Jan 2022 20:54:21 +0100 Subject: [PATCH 09/12] =?UTF-8?q?feat:=20=E2=9C=A8=20Added=20"voucher"=20a?= =?UTF-8?q?s=20store=20parameter=20->=20opens=20voucher=20redeem=20modal?= =?UTF-8?q?=20and=20fill=20the=20input?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/views/layouts/main.blade.php | 791 +++++++++++++------------ resources/views/store/index.blade.php | 19 + 2 files changed, 417 insertions(+), 393 deletions(-) diff --git a/resources/views/layouts/main.blade.php b/resources/views/layouts/main.blade.php index 453258e6..ab4179ef 100644 --- a/resources/views/layouts/main.blade.php +++ b/resources/views/layouts/main.blade.php @@ -1,5 +1,6 @@ + @@ -7,442 +8,446 @@ {{ config('app.name', 'Laravel') }} + href="{{ \Illuminate\Support\Facades\Storage::disk('public')->exists('favicon.ico') ? asset('storage/favicon.ico') : asset('favicon.ico') }}" + type="image/x-icon"> - {{-- --}} - + {{-- --}} + - {{-- summernote --}} - + {{-- summernote --}} + - {{-- datetimepicker --}} - + {{-- datetimepicker --}} + {{-- select2 --}} - + - - + + - -
- - + + + + - + -
+ - @if(!Auth::user()->hasVerifiedEmail()) - @if(Auth::user()->created_at->diffInHours(now(), false) > 1) -
-
{{__('Warning!')}}
- {{__('You have not yet verified your email address')}} {{__('Click here to resend verification email')}} -
- {{__('Please contact support If you didnt receive your verification email.')}} -
+ + + + + + + + + + + + + + + + + {{-- --}} + + {{-- --}} + + {{-- --}} + + + + + + + + + + + + + @endif + + + + +
+ + + + + +
+ + @if (!Auth::user()->hasVerifiedEmail()) + @if (Auth::user()->created_at->diffInHours(now(), false) > 1) +
+
{{ __('Warning!') }}
+ {{ __('You have not yet verified your email address') }} {{ __('Click here to resend verification email') }} +
+ {{ __('Please contact support If you didnt receive your verification email.') }} +
+ @endif @endif - @endif - @yield('content') + @yield('content') - @include('models.redeem_voucher_modal') + @include('models.redeem_voucher_modal') +
+ + + + + +
- - - - - - -
- - - -{{----}} -{{----}} -{{----}} -{{----}} - - - - - - - - - - - - - - - - - + + } + }) + @endif + + diff --git a/resources/views/store/index.blade.php b/resources/views/store/index.blade.php index f7399165..0b6220b2 100644 --- a/resources/views/store/index.blade.php +++ b/resources/views/store/index.blade.php @@ -81,4 +81,23 @@ + + + @endsection From 7c4622c622e988acc8473c58a596b48b0e44f373 Mon Sep 17 00:00:00 2001 From: LogischJo <66436499+LogischJo@users.noreply.github.com> Date: Wed, 5 Jan 2022 18:08:41 +0100 Subject: [PATCH 10/12] Update UserController.php --- app/Http/Controllers/Api/UserController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index c2ad37f0..47693c48 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -205,7 +205,7 @@ class UserController extends Controller } /** - * Suspends the user + * Unsuspend the user * * @param Request $request * @param int $id From 0c2cf8712ee3498e7d7914676f19c26e1eed142b Mon Sep 17 00:00:00 2001 From: Dennis Date: Mon, 10 Jan 2022 21:02:43 +0100 Subject: [PATCH 11/12] Translation String --- app/Http/Controllers/Auth/RegisterController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 58034a42..34bc79e0 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -67,7 +67,7 @@ class RegisterController extends Controller 'g-recaptcha-response' => ['recaptcha'], 'ip' => ['unique:users'], ], [ - 'ip.unique' => "You have already made an account with us! Please contact support if you think this is incorrect." + 'ip.unique' => __("You have already made an account with us! Please contact support if you think this is incorrect.") ]); } From 5dc5b8a95a9d70a01608a9458fb657378631e325 Mon Sep 17 00:00:00 2001 From: IceToast Date: Thu, 20 Jan 2022 09:31:28 +0100 Subject: [PATCH 12/12] =?UTF-8?q?fix:=20=F0=9F=9A=91=EF=B8=8F=20removed=20?= =?UTF-8?q?old=20migration=20renaming=20(wrong=20one)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...=> 2021_05_08_081218_create_paypal_products_table.php} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename database/migrations/{2021_05_08_081218_create_credit_products_table.php => 2021_05_08_081218_create_paypal_products_table.php} (76%) diff --git a/database/migrations/2021_05_08_081218_create_credit_products_table.php b/database/migrations/2021_05_08_081218_create_paypal_products_table.php similarity index 76% rename from database/migrations/2021_05_08_081218_create_credit_products_table.php rename to database/migrations/2021_05_08_081218_create_paypal_products_table.php index 2c4d1394..207e4313 100644 --- a/database/migrations/2021_05_08_081218_create_credit_products_table.php +++ b/database/migrations/2021_05_08_081218_create_paypal_products_table.php @@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateCreditProductsTable extends Migration +class CreatePaypalProductsTable extends Migration { /** * Run the migrations. @@ -13,13 +13,13 @@ class CreateCreditProductsTable extends Migration */ public function up() { - Schema::create('credit_products', function (Blueprint $table) { + Schema::create('paypal_products', function (Blueprint $table) { $table->uuid('id')->primary(); $table->string('type'); $table->decimal('price')->default(0); $table->unsignedInteger('quantity'); $table->string('description'); - $table->string('currency_code' , 3); + $table->string('currency_code', 3); $table->boolean('disabled')->default(true); $table->timestamps(); }); @@ -32,6 +32,6 @@ class CreateCreditProductsTable extends Migration */ public function down() { - Schema::dropIfExists('credit_products'); + Schema::dropIfExists('paypal_products'); } }