mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 10:03:34 -05:00 
			
		
		
		
	Fixes for domain validation
This commit is contained in:
		
							parent
							
								
									2ed241e7c8
								
							
						
					
					
						commit
						f501a42e35
					
				@ -15,6 +15,22 @@ use App\Libraries\MultiDB;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class SubdomainController extends BaseController
 | 
					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()
 | 
					    public function __construct()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@ -29,7 +45,7 @@ class SubdomainController extends BaseController
 | 
				
			|||||||
    public function index()
 | 
					    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 not available'] , 401);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return response()->json(['message' => 'Domain available'], 200);
 | 
					        return response()->json(['message' => 'Domain available'], 200);
 | 
				
			||||||
 | 
				
			|||||||
@ -34,13 +34,15 @@ class StoreCompanyRequest extends Request
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function rules()
 | 
					    public function rules()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        $input = $this->all();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $rules = [];
 | 
					        $rules = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $rules['name'] = new ValidCompanyQuantity();
 | 
					        $rules['name'] = new ValidCompanyQuantity();
 | 
				
			||||||
        $rules['company_logo'] = 'mimes:jpeg,jpg,png,gif|max:10000'; // max 10000kb
 | 
					        $rules['company_logo'] = 'mimes:jpeg,jpg,png,gif|max:10000'; // max 10000kb
 | 
				
			||||||
        $rules['settings'] = new ValidSettingsRule();
 | 
					        $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';
 | 
					            $rules['portal_domain'] = 'sometimes|url';
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $rules['portal_domain'] = 'nullable|alpha_num';
 | 
					            $rules['portal_domain'] = 'nullable|alpha_num';
 | 
				
			||||||
 | 
				
			|||||||
@ -32,6 +32,8 @@ class UpdateCompanyRequest extends Request
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function rules()
 | 
					    public function rules()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        $input = $this->all();
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        $rules = [];
 | 
					        $rules = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $rules['company_logo'] = 'mimes:jpeg,jpg,png,gif|max:10000'; // max 10000kb
 | 
					        $rules['company_logo'] = 'mimes:jpeg,jpg,png,gif|max:10000'; // max 10000kb
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user