Fixes for domain validation

This commit is contained in:
David Bomba 2021-04-28 13:12:51 +10:00
parent 2ed241e7c8
commit f501a42e35
3 changed files with 22 additions and 2 deletions

View File

@ -15,6 +15,22 @@ use App\Libraries\MultiDB;
class SubdomainController extends BaseController
{
private $protected = [
'www',
'v5-app1',
'v5-app2',
'v5-db1',
'v5-db2',
'app',
'ninja',
'sentry',
'staging',
'pdf',
'demo',
'docs',
'client_domain',
'custom_domain',
];
public function __construct()
{
@ -29,7 +45,7 @@ class SubdomainController extends BaseController
public function index()
{
if( MultiDB::findAndSetDbByDomain(request()->input('subdomain')) )
if(in_array(request()->input('subdomain'), $this->protected) || MultiDB::findAndSetDbByDomain(request()->input('subdomain')))
return response()->json(['message' => 'Domain not available'] , 401);
return response()->json(['message' => 'Domain available'], 200);

View File

@ -34,13 +34,15 @@ class StoreCompanyRequest extends Request
public function rules()
{
$input = $this->all();
$rules = [];
$rules['name'] = new ValidCompanyQuantity();
$rules['company_logo'] = 'mimes:jpeg,jpg,png,gif|max:10000'; // max 10000kb
$rules['settings'] = new ValidSettingsRule();
if (isset($rules['portal_mode']) && ($rules['portal_mode'] == 'domain' || $rules['portal_mode'] == 'iframe')) {
if (isset($input['portal_mode']) && ($input['portal_mode'] == 'domain' || $input['portal_mode'] == 'iframe')) {
$rules['portal_domain'] = 'sometimes|url';
} else {
$rules['portal_domain'] = 'nullable|alpha_num';

View File

@ -32,6 +32,8 @@ class UpdateCompanyRequest extends Request
public function rules()
{
$input = $this->all();
$rules = [];
$rules['company_logo'] = 'mimes:jpeg,jpg,png,gif|max:10000'; // max 10000kb