Merge branch 'development' into settings_rewrite
This commit is contained in:
commit
9b797cf779
10 changed files with 176 additions and 16 deletions
|
@ -270,7 +270,7 @@ class PaymentController extends Controller
|
||||||
],
|
],
|
||||||
|
|
||||||
'mode' => 'payment',
|
'mode' => 'payment',
|
||||||
"payment_method_types" => str_getcsv(Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:METHODS")),
|
"payment_method_types" => str_getcsv(config("SETTINGS::PAYMENTS:STRIPE:METHODS")),
|
||||||
'success_url' => route('payment.StripeSuccess', ['product' => $creditProduct->id]) . '&session_id={CHECKOUT_SESSION_ID}',
|
'success_url' => route('payment.StripeSuccess', ['product' => $creditProduct->id]) . '&session_id={CHECKOUT_SESSION_ID}',
|
||||||
'cancel_url' => route('payment.Cancel'),
|
'cancel_url' => route('payment.Cancel'),
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -88,10 +88,25 @@ class UserController extends Controller
|
||||||
"role" => ['sometimes', Rule::in(['admin', 'mod', 'client', 'member'])],
|
"role" => ['sometimes', Rule::in(['admin', 'mod', 'client', 'member'])],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$user->update($request->all());
|
|
||||||
|
|
||||||
event(new UserUpdateCreditsEvent($user));
|
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;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +181,53 @@ class UserController extends Controller
|
||||||
return $user;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unsuspend 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
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -12,6 +12,7 @@ use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
class RegisterController extends Controller
|
class RegisterController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -68,9 +69,9 @@ class RegisterController extends Controller
|
||||||
$data['ip'] = session()->get('ip') ?? request()->ip();
|
$data['ip'] = session()->get('ip') ?? request()->ip();
|
||||||
if (User::where('ip', '=', request()->ip())->exists()) session()->put('ip', request()->ip());
|
if (User::where('ip', '=', request()->ip())->exists()) session()->put('ip', request()->ip());
|
||||||
$validationRules['ip'] = ['unique:users'];
|
$validationRules['ip'] = ['unique:users'];
|
||||||
|
|
||||||
return Validator::make($data, $validationRules, [
|
return Validator::make($data, $validationRules, [
|
||||||
'ip.unique' => "You have already made an account! Please contact support if you think this is incorrect."
|
'ip.unique' => "You have already made an account! Please contact support if you think this is incorrect."
|
||||||
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,13 +107,17 @@ class RegisterController extends Controller
|
||||||
|
|
||||||
if ($response->failed()) {
|
if ($response->failed()) {
|
||||||
$user->delete();
|
$user->delete();
|
||||||
return $user;
|
throw ValidationException::withMessages([
|
||||||
|
'ptero_registration_error' => [__('Account already exists on Pterodactyl. Please contact the Support!')],
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->update([
|
$user->update([
|
||||||
'pterodactyl_id' => $response->json()['attributes']['id']
|
'pterodactyl_id' => $response->json()['attributes']['id']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,14 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\Settings;
|
|
||||||
|
use App\Classes\Pterodactyl;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
class ProfileController extends Controller
|
class ProfileController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -50,10 +52,27 @@ class ProfileController extends Controller
|
||||||
'new_password_confirmation' => 'required|same:new_password'
|
'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
|
//update password
|
||||||
$user->update([
|
$user->update([
|
||||||
'password' => Hash::make($request->input('new_password')),
|
'password' => Hash::make($request->input('new_password')),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//validate request
|
//validate request
|
||||||
|
@ -77,11 +96,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
|
//update name and email
|
||||||
$user->update([
|
$user->update([
|
||||||
'name' => $request->input('name'),
|
'name' => $request->input('name'),
|
||||||
'email' => $request->input('email'),
|
'email' => $request->input('email'),
|
||||||
]);
|
]);
|
||||||
|
$user->sendEmailVerificationNotification();
|
||||||
|
|
||||||
return redirect()->route('profile.index')->with('success', __('Profile updated'));
|
return redirect()->route('profile.index')->with('success', __('Profile updated'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
class CreateCreditProductsTable extends Migration
|
class CreatePaypalProductsTable extends Migration
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
|
@ -13,13 +13,13 @@ class CreateCreditProductsTable extends Migration
|
||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::create('credit_products', function (Blueprint $table) {
|
Schema::create('paypal_products', function (Blueprint $table) {
|
||||||
$table->uuid('id')->primary();
|
$table->uuid('id')->primary();
|
||||||
$table->string('type');
|
$table->string('type');
|
||||||
$table->decimal('price')->default(0);
|
$table->decimal('price')->default(0);
|
||||||
$table->unsignedInteger('quantity');
|
$table->unsignedInteger('quantity');
|
||||||
$table->string('description');
|
$table->string('description');
|
||||||
$table->string('currency_code' , 3);
|
$table->string('currency_code', 3);
|
||||||
$table->boolean('disabled')->default(true);
|
$table->boolean('disabled')->default(true);
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
@ -32,6 +32,6 @@ class CreateCreditProductsTable extends Migration
|
||||||
*/
|
*/
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('credit_products');
|
Schema::dropIfExists('paypal_products');
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -23,6 +23,13 @@
|
||||||
<small><strong>{{ $message }}</strong></small>
|
<small><strong>{{ $message }}</strong></small>
|
||||||
</span>
|
</span>
|
||||||
@enderror
|
@enderror
|
||||||
|
@if( $errors->has('ptero_registration_error') )
|
||||||
|
@foreach( $errors->get('ptero_registration_error') as $err )
|
||||||
|
<span class="text-danger" role="alert">
|
||||||
|
<small><strong>{{ $err }}</strong></small>
|
||||||
|
</span>
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
|
|
||||||
@csrf
|
@csrf
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
|
@ -36,6 +36,24 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="sidebar-mini layout-fixed dark-mode" style="height: auto;">
|
<body class="sidebar-mini layout-fixed dark-mode" style="height: auto;">
|
||||||
|
<!-- Scripts -->
|
||||||
|
<script src="{{ asset('js/app.js') }}"></script>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10.14.1/dist/sweetalert2.all.min.js"></script>
|
||||||
|
<script type="text/javascript" src="https://cdn.datatables.net/v/bs4/dt-1.10.24/datatables.min.js"></script>
|
||||||
|
<!-- Summernote -->
|
||||||
|
<script src="{{ asset('plugins/summernote/summernote-bs4.min.js') }}"></script>
|
||||||
|
<!-- select2 -->
|
||||||
|
<script src="{{ asset('plugins/select2/js/select2.min.js') }}"></script>
|
||||||
|
|
||||||
|
<!-- Moment.js -->
|
||||||
|
<script src="{{ asset('plugins/moment/moment.min.js') }}"></script>
|
||||||
|
|
||||||
|
<!-- Datetimepicker -->
|
||||||
|
<script src="{{ asset('plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js') }}"></script>
|
||||||
|
|
||||||
|
<!-- Select2 -->
|
||||||
|
<script src={{ asset('plugins/select2/js/select2.min.js') }}></script>
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<!-- Navbar -->
|
<!-- Navbar -->
|
||||||
<nav class="main-header sticky-top navbar navbar-expand navbar-dark navbar-light">
|
<nav class="main-header sticky-top navbar navbar-expand navbar-dark navbar-light">
|
||||||
|
@ -425,7 +443,6 @@
|
||||||
html: '{{ Session::get('error') }}',
|
html: '{{ Session::get('error') }}',
|
||||||
})
|
})
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if (Session::has('success'))
|
@if (Session::has('success'))
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
|
|
|
@ -36,14 +36,14 @@
|
||||||
href="{{ route('verification.send') }}">{{ __('Click here to resend verification email') }}</a>
|
href="{{ route('verification.send') }}">{{ __('Click here to resend verification email') }}</a>
|
||||||
<br>
|
<br>
|
||||||
{{ __('Please contact support If you didnt receive your verification email.') }}
|
{{ __('Please contact support If you didnt receive your verification email.') }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if (is_null(Auth::user()->discordUser) && strtolower($force_discord_verification) == 'true')
|
@if (is_null(Auth::user()->discordUser) && strtolower($force_discord_verification) == 'true')
|
||||||
@if (!empty(config('SETTINGS::DISCORD:CLIENT_ID')) && !empty(config('SETTINGS::DISCORD:CLIENT_SECRET')))
|
@if (!empty(config('SETTINGS::DISCORD:CLIENT_ID')) && !empty(config('SETTINGS::DISCORD:CLIENT_SECRET')))
|
||||||
<div class="alert alert-warning p-2 m-2">
|
<div class="alert alert-warning p-2 m-2">
|
||||||
<h5><i
|
<h5><i class="icon fas fa-exclamation-circle"></i>{{ __('Required Discord verification!') }}
|
||||||
class="icon fas fa-exclamation-circle"></i>{{ __('Required Discord verification!') }}
|
|
||||||
</h5>
|
</h5>
|
||||||
{{ __('You have not yet verified your discord account') }}
|
{{ __('You have not yet verified your discord account') }}
|
||||||
<a class="text-primary"
|
<a class="text-primary"
|
||||||
|
@ -52,8 +52,7 @@
|
||||||
</div>
|
</div>
|
||||||
@else
|
@else
|
||||||
<div class="alert alert-danger p-2 m-2">
|
<div class="alert alert-danger p-2 m-2">
|
||||||
<h5><i
|
<h5><i class="icon fas fa-exclamation-circle"></i>{{ __('Required Discord verification!') }}
|
||||||
class="icon fas fa-exclamation-circle"></i>{{ __('Required Discord verification!') }}
|
|
||||||
</h5>
|
</h5>
|
||||||
{{ __('Due to system settings you are required to verify your discord account!') }} <br>
|
{{ __('Due to system settings you are required to verify your discord account!') }} <br>
|
||||||
{{ __('It looks like this hasnt been set-up correctly! Please contact support.') }}'
|
{{ __('It looks like this hasnt been set-up correctly! Please contact support.') }}'
|
||||||
|
@ -117,7 +116,21 @@
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="form-group"><label>{{ __('Name') }}</label> <input
|
@if( $errors->has('pterodactyl_error_message') )
|
||||||
|
@foreach( $errors->get('pterodactyl_error_message') as $err )
|
||||||
|
<span class="text-danger" role="alert">
|
||||||
|
<small><strong>{{ $err }}</strong></small>
|
||||||
|
</span>
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
|
@if( $errors->has('pterodactyl_error_status') )
|
||||||
|
@foreach( $errors->get('pterodactyl_error_status') as $err )
|
||||||
|
<span class="text-danger" role="alert">
|
||||||
|
<small><strong>{{ $err }}</strong></small>
|
||||||
|
</span>
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
|
<div class="form-group"><label>{{__('Name')}}</label> <input
|
||||||
class="form-control @error('name') is-invalid @enderror"
|
class="form-control @error('name') is-invalid @enderror"
|
||||||
type="text" name="name" placeholder="{{ $user->name }}"
|
type="text" name="name" placeholder="{{ $user->name }}"
|
||||||
value="{{ $user->name }}">
|
value="{{ $user->name }}">
|
||||||
|
|
|
@ -81,4 +81,23 @@
|
||||||
</section>
|
</section>
|
||||||
<!-- END CONTENT -->
|
<!-- END CONTENT -->
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const getUrlParameter = (param) => {
|
||||||
|
const queryString = window.location.search;
|
||||||
|
const urlParams = new URLSearchParams(queryString);
|
||||||
|
return urlParams.get(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
const voucherCode = getUrlParameter('voucher');
|
||||||
|
//if voucherCode not empty, open the modal and fill the input
|
||||||
|
if (voucherCode) {
|
||||||
|
$(function() {
|
||||||
|
$('#redeemVoucherModal').modal('show');
|
||||||
|
$('#redeemVoucherCode').val(voucherCode);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
|
@ -20,6 +20,8 @@ use Illuminate\Support\Facades\Route;
|
||||||
Route::middleware('api.token')->group(function () {
|
Route::middleware('api.token')->group(function () {
|
||||||
Route::patch('/users/{user}/increment', [UserController::class, 'increment']);
|
Route::patch('/users/{user}/increment', [UserController::class, 'increment']);
|
||||||
Route::patch('/users/{user}/decrement', [UserController::class, 'decrement']);
|
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::resource('users', UserController::class)->except(['create']);
|
||||||
|
|
||||||
Route::patch('/servers/{server}/suspend', [ServerController::class, 'suspend']);
|
Route::patch('/servers/{server}/suspend', [ServerController::class, 'suspend']);
|
||||||
|
|
Loading…
Reference in a new issue