Merge pull request #348 from 1day2die/update_user_updates_pterodactyl
Update user on cpgg updates user on pterodactyl
This commit is contained in:
commit
0bfecf6633
|
@ -88,9 +88,24 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Classes\Pterodactyl;
|
||||||
use App\Models\Configuration;
|
use App\Models\Configuration;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
|
@ -11,6 +12,7 @@ use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
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
|
||||||
{
|
{
|
||||||
|
@ -53,10 +55,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
|
||||||
|
@ -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
|
//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'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<ol class="breadcrumb float-sm-right">
|
<ol class="breadcrumb float-sm-right">
|
||||||
<li class="breadcrumb-item"><a href="{{route('home')}}">{{__('Dashboard')}}</a></li>
|
<li class="breadcrumb-item"><a href="{{route('home')}}">{{__('Dashboard')}}</a></li>
|
||||||
<li class="breadcrumb-item"><a class="text-muted" href="{{route('profile.index')}}">{{__('Profile')}}</a>
|
<li class="breadcrumb-item"><a class="text-muted"
|
||||||
|
href="{{route('profile.index')}}">{{__('Profile')}}</a>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
|
@ -28,9 +29,12 @@
|
||||||
<div class="col-lg-12 px-0">
|
<div class="col-lg-12 px-0">
|
||||||
@if(!Auth::user()->hasVerifiedEmail() && strtolower($force_email_verification) == 'true')
|
@if(!Auth::user()->hasVerifiedEmail() && strtolower($force_email_verification) == 'true')
|
||||||
<div class="alert alert-warning p-2 m-2">
|
<div class="alert alert-warning p-2 m-2">
|
||||||
<h5><i class="icon fas fa-exclamation-circle"></i>{{__('Required Email verification!')}}</h5>
|
<h5><i class="icon fas fa-exclamation-circle"></i>{{__('Required Email verification!')}}
|
||||||
|
</h5>
|
||||||
{{__('You have not yet verified your email address')}}
|
{{__('You have not yet verified your email address')}}
|
||||||
<a class="text-primary" href="{{route('verification.send')}}">{{__('Click here to resend verification email')}}</a> <br>
|
<a class="text-primary"
|
||||||
|
href="{{route('verification.send')}}">{{__('Click here to resend verification email')}}</a>
|
||||||
|
<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
|
||||||
|
@ -38,14 +42,19 @@
|
||||||
@if(is_null(Auth::user()->discordUser) && strtolower($force_discord_verification) == 'true')
|
@if(is_null(Auth::user()->discordUser) && strtolower($force_discord_verification) == 'true')
|
||||||
@if(!empty(env('DISCORD_CLIENT_ID')) && !empty(env('DISCORD_CLIENT_SECRET')))
|
@if(!empty(env('DISCORD_CLIENT_ID')) && !empty(env('DISCORD_CLIENT_SECRET')))
|
||||||
<div class="alert alert-warning p-2 m-2">
|
<div class="alert alert-warning p-2 m-2">
|
||||||
<h5><i class="icon fas fa-exclamation-circle"></i>{{__('Required Discord verification!')}}</h5>
|
<h5>
|
||||||
|
<i class="icon fas fa-exclamation-circle"></i>{{__('Required Discord verification!')}}
|
||||||
|
</h5>
|
||||||
{{__('You have not yet verified your discord account')}}
|
{{__('You have not yet verified your discord account')}}
|
||||||
<a class="text-primary" href="{{route('auth.redirect')}}">{{__('Login with discord')}}</a> <br>
|
<a class="text-primary"
|
||||||
|
href="{{route('auth.redirect')}}">{{__('Login with discord')}}</a> <br>
|
||||||
{{__('Please contact support If you face any issues.')}}
|
{{__('Please contact support If you face any issues.')}}
|
||||||
</div>
|
</div>
|
||||||
@else
|
@else
|
||||||
<div class="alert alert-danger p-2 m-2">
|
<div class="alert alert-danger p-2 m-2">
|
||||||
<h5><i class="icon fas fa-exclamation-circle"></i>{{__('Required Discord verification!')}}</h5>
|
<h5>
|
||||||
|
<i class="icon fas fa-exclamation-circle"></i>{{__('Required Discord verification!')}}
|
||||||
|
</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.')}}'
|
||||||
</div>
|
</div>
|
||||||
|
@ -99,7 +108,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ul class="nav nav-tabs">
|
<ul class="nav nav-tabs">
|
||||||
<li class="nav-item"><a href="javasript:void(0)" class="active nav-link">{{__('Settings')}}</a>
|
<li class="nav-item"><a href="javasript:void(0)"
|
||||||
|
class="active nav-link">{{__('Settings')}}</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content pt-3">
|
<div class="tab-content pt-3">
|
||||||
|
@ -108,6 +118,20 @@
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
@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
|
<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"
|
type="text" name="name"
|
||||||
|
@ -144,7 +168,8 @@
|
||||||
<div class="mb-3"><b>{{__('Change Password')}}</b></div>
|
<div class="mb-3"><b>{{__('Change Password')}}</b></div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="form-group"><label>{{__('Current Password')}}</label> <input
|
<div class="form-group"><label>{{__('Current Password')}}</label>
|
||||||
|
<input
|
||||||
class="form-control @error('current_password') is-invalid @enderror"
|
class="form-control @error('current_password') is-invalid @enderror"
|
||||||
name="current_password" type="password"
|
name="current_password" type="password"
|
||||||
placeholder="••••••">
|
placeholder="••••••">
|
||||||
|
@ -173,7 +198,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="form-group"><label>{{__('Confirm Password')}}</span></label>
|
<div class="form-group">
|
||||||
|
<label>{{__('Confirm Password')}}</span></label>
|
||||||
<input
|
<input
|
||||||
class="form-control @error('new_password_confirmation') is-invalid @enderror"
|
class="form-control @error('new_password_confirmation') is-invalid @enderror"
|
||||||
name="new_password_confirmation" type="password"
|
name="new_password_confirmation" type="password"
|
||||||
|
@ -238,7 +264,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col d-flex justify-content-end">
|
<div class="col d-flex justify-content-end">
|
||||||
<button class="btn btn-primary" type="submit">{{__('Save Changes')}}</button>
|
<button class="btn btn-primary"
|
||||||
|
type="submit">{{__('Save Changes')}}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue