|
@@ -8,9 +8,10 @@ use App\Models\Configuration;
|
|
use App\Models\User;
|
|
use App\Models\User;
|
|
use App\Providers\RouteServiceProvider;
|
|
use App\Providers\RouteServiceProvider;
|
|
use Illuminate\Foundation\Auth\RegistersUsers;
|
|
use Illuminate\Foundation\Auth\RegistersUsers;
|
|
|
|
+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\Validation\ValidationException;
|
|
|
|
|
|
+use Illuminate\Support\Str;
|
|
|
|
|
|
class RegisterController extends Controller
|
|
class RegisterController extends Controller
|
|
{
|
|
{
|
|
@@ -52,39 +53,50 @@ class RegisterController extends Controller
|
|
*/
|
|
*/
|
|
protected function validator(array $data)
|
|
protected function validator(array $data)
|
|
{
|
|
{
|
|
- //check if ip has already made an account
|
|
|
|
- $data['ip'] = session()->get('ip') ?? request()->ip();
|
|
|
|
- if (User::where('ip', '=', request()->ip())->exists()) session()->put('ip', request()->ip());
|
|
|
|
|
|
+ if (Configuration::getValueByKey('REGISTER_IP_CHECK', 'true') == 'true') {
|
|
|
|
+
|
|
|
|
+ //check if ip has already made an account
|
|
|
|
+ $data['ip'] = session()->get('ip') ?? request()->ip();
|
|
|
|
+ if (User::where('ip', '=', request()->ip())->exists()) session()->put('ip', request()->ip());
|
|
|
|
+
|
|
|
|
+ return Validator::make($data, [
|
|
|
|
+ 'name' => ['required', 'string', 'max:30', 'min:4', 'alpha_num', 'unique:users'],
|
|
|
|
+ 'email' => ['required', 'string', 'email', 'max:64', 'unique:users'],
|
|
|
|
+ 'password' => ['required', 'string', 'min:8', 'confirmed'],
|
|
|
|
+ '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."
|
|
|
|
+ ]);
|
|
|
|
+ }
|
|
|
|
|
|
return Validator::make($data, [
|
|
return Validator::make($data, [
|
|
'name' => ['required', 'string', 'max:30', 'min:4', 'alpha_num', 'unique:users'],
|
|
'name' => ['required', 'string', 'max:30', 'min:4', 'alpha_num', 'unique:users'],
|
|
'email' => ['required', 'string', 'email', 'max:64', 'unique:users'],
|
|
'email' => ['required', 'string', 'email', 'max:64', 'unique:users'],
|
|
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
|
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
|
'g-recaptcha-response' => ['recaptcha'],
|
|
'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."
|
|
|
|
]);
|
|
]);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* Create a new user instance after a valid registration.
|
|
* Create a new user instance after a valid registration.
|
|
*
|
|
*
|
|
* @param array $data
|
|
* @param array $data
|
|
- * @return User|\Illuminate\Http\RedirectResponse
|
|
|
|
|
|
+ * @return User
|
|
*/
|
|
*/
|
|
protected function create(array $data)
|
|
protected function create(array $data)
|
|
{
|
|
{
|
|
$user = User::create([
|
|
$user = User::create([
|
|
'name' => $data['name'],
|
|
'name' => $data['name'],
|
|
'email' => $data['email'],
|
|
'email' => $data['email'],
|
|
- 'credits' => Configuration::getValueByKey('INITIAL_CREDITS'),
|
|
|
|
- 'server_limit' => Configuration::getValueByKey('INITIAL_SERVER_LIMIT'),
|
|
|
|
|
|
+ 'credits' => Configuration::getValueByKey('INITIAL_CREDITS', 150),
|
|
|
|
+ 'server_limit' => Configuration::getValueByKey('INITIAL_SERVER_LIMIT', 1),
|
|
'password' => Hash::make($data['password']),
|
|
'password' => Hash::make($data['password']),
|
|
]);
|
|
]);
|
|
|
|
|
|
$response = Pterodactyl::client()->post('/application/users', [
|
|
$response = Pterodactyl::client()->post('/application/users', [
|
|
- "external_id" => (string)$user->id,
|
|
|
|
|
|
+ "external_id" => App::environment('local') ? Str::random(16) : (string)$user->id,
|
|
"username" => $user->name,
|
|
"username" => $user->name,
|
|
"email" => $user->email,
|
|
"email" => $user->email,
|
|
"first_name" => $user->name,
|
|
"first_name" => $user->name,
|
|
@@ -96,7 +108,6 @@ class RegisterController extends Controller
|
|
|
|
|
|
if ($response->failed()) {
|
|
if ($response->failed()) {
|
|
$user->delete();
|
|
$user->delete();
|
|
- redirect()->route('register')->with('error', 'pterodactyl error');
|
|
|
|
return $user;
|
|
return $user;
|
|
}
|
|
}
|
|
|
|
|