1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Subdomain checks for hosted

This commit is contained in:
David Bomba 2021-03-22 22:38:09 +11:00
parent dd46e6384a
commit 0d44249f41
2 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,39 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Controllers;
use App\Libraries\MultiDB;
class SubdomainController extends BaseController
{
public function __construct()
{
}
/**
* Display a listing of the resource.
*
* @return void
*/
public function index()
{
$subdomain_exists = MultiDB::findAndSetDbByDomain(request()->input('subdomain'));
if($subdomain_exists)
return response()->json(['message' => 'Domain not available'] , 401);
return response()->json(['message' => 'Domain available'], 200);
}
}

View File

@ -24,6 +24,7 @@ Route::group(['middleware' => ['api_secret_check', 'email_db']], function () {
});
Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'api/v1', 'as' => 'api.'], function () {
Route::post('check_subdomain', 'SubdomainController@index')->name('check_subdomain');
Route::get('ping', 'PingController@index')->name('ping');
Route::get('health_check', 'PingController@health')->name('health_check');