1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
invoiceninja/app/Http/Controllers/SubdomainController.php

41 lines
1.0 KiB
PHP
Raw Normal View History

2021-03-22 21:09:42 +01:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2024-04-12 06:15:41 +02:00
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
2021-03-22 21:09:42 +01:00
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2021-03-22 21:09:42 +01:00
*/
namespace App\Http\Controllers;
use App\Libraries\MultiDB;
class SubdomainController extends BaseController
{
public function __construct()
{
}
/**
2023-06-07 03:21:26 +02:00
* Return if a subdomain is available.
2021-03-22 21:09:42 +01:00
*
*/
public function index()
{
2023-06-07 03:21:26 +02:00
if (!MultiDB::checkDomainAvailable(request()->input('subdomain'))) {
2023-11-26 08:41:42 +01:00
return response()->json(['message' => ctrans('texts.subdomain_is_not_available')], 401);
}
2021-03-22 21:09:42 +01:00
2023-12-08 02:57:34 +01:00
if (!preg_match('/^[A-Za-z0-9](?:[A-Za-z0-9\-]{0,61}[A-Za-z0-9])?$/', request()->input('subdomain'))) {
return response()->json(['message' => ctrans('texts.subdomain_is_not_available')], 401);
}
2021-03-22 21:09:42 +01:00
return response()->json(['message' => 'Domain available'], 200);
}
}