Do this check server sided

This commit is contained in:
Dennis Smink
2022-07-20 08:16:42 +02:00
parent 2df031a60f
commit 75592aaeb2
5 changed files with 518 additions and 556 deletions

View File

@@ -39,6 +39,12 @@ class SiteController extends Controller
public function store(SiteRequest $request)
{
if (Site::query()->where('domain', $request->input('domain'))->exists()) {
return redirect()->back()->withErrors([
'domain' => 'This domain is not available.'
]);
}
if ($serverId = $request->input('server_id')) {
$server = $request->user()->servers()->findOrFail($serverId);
} else {
@@ -143,19 +149,4 @@ class SiteController extends Controller
return ['ftp_password' => decrypt(Arr::get($systemUser, 'ftp_password'))];
}
public function checkDomainExistence(Request $request): JsonResponse
{
$domainToCheck = $request->input('domain');
if (! $domainToCheck) {
return response()->json(['result' => null]);
}
$exists = Site::whereDomain($domainToCheck)->exists();
return response()->json([
'result' => $exists
]);
}
}

16
public/css/app.css vendored
View File

@@ -1806,10 +1806,6 @@ select {
.text-on-warning {
color: var(--color-text-on-warning);
}
.text-red-500 {
--tw-text-opacity: 1;
color: rgb(239 68 68 / var(--tw-text-opacity));
}
.text-orange-600 {
--tw-text-opacity: 1;
color: rgb(234 88 12 / var(--tw-text-opacity));
@@ -1818,17 +1814,9 @@ select {
--tw-text-opacity: 1;
color: rgb(107 114 128 / var(--tw-text-opacity));
}
.text-green-500 {
.text-red-500 {
--tw-text-opacity: 1;
color: rgb(34 197 94 / var(--tw-text-opacity));
}
.text-green-600 {
--tw-text-opacity: 1;
color: rgb(22 163 74 / var(--tw-text-opacity));
}
.text-green-700 {
--tw-text-opacity: 1;
color: rgb(21 128 61 / var(--tw-text-opacity));
color: rgb(239 68 68 / var(--tw-text-opacity));
}
.underline {
-webkit-text-decoration-line: underline;

1020
public/js/app.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -8,10 +8,6 @@
<template #form>
<FormInput :label="__('Domain')" :errors="$page.props.errors.domain" v-model="form.domain"/>
<div class="text-sm">
<p class="text-orange-600" v-if="domainExists === true">{{ __('Warning: domain already exists.') }}</p>
</div>
<FormSelect v-if="Object.keys(availableServers).length" :label="__('Select server')" v-model="form.server_id">
<option :value="`${null}`">{{ __('Select random server') }}</option>
<option v-for="(name, id) in availableServers" :value="id" v-text="name"></option>
@@ -120,7 +116,6 @@ import DropdownListItem from '@/components/DropdownListItem'
import DropdownListItemButton from '@/components/DropdownListItemButton'
import {useConfirm} from '@/hooks/confirm'
import Pagination from '@/components/Pagination'
import debounce from "lodash/debounce";
export default {
@@ -205,10 +200,6 @@ export default {
this.startPollingInterval();
}
},
'form.domain': debounce(function(value) {
this.checkDomainExistence();
}, 200)
},
data() {
@@ -261,13 +252,6 @@ export default {
this.$page.props.errors = [];
},
checkDomainExistence() {
window.axios.post(this.route('sites.check-domain-existence'), {domain: this.form.domain}).then(response => {
console.log(response.data);
this.domainExists = response.data.result;
});
},
submit() {
this.$inertia.post(this.route('sites.store'), this.form, {
only: ['errors', 'flash', 'sites'],

View File

@@ -34,7 +34,6 @@ Route::group(['middleware' => ['auth', 'auth.blocked']], function () {
Route::delete('{site}', 'SiteController@destroy')->name('delete');
Route::post('/', 'SiteController@store')->name('store');
Route::post('{site}/request-ftp-password', 'SiteController@requestFtpPassword')->name('request-ftp-password');
Route::post('check-domain-existence', 'SiteController@checkDomainExistence')->name('check-domain-existence');
Route::get('{site}/settings', 'SiteSettingController@show')->name('settings.show');
Route::patch('{site}/settings', 'SiteSettingController@update')->name('settings.update');