mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 20:52:56 +01:00
Multi-db support
This commit is contained in:
parent
9c70ca63f3
commit
479340c07a
@ -9,7 +9,7 @@ use App\Models\LookupCompany;
|
||||
use App\Models\LookupAccount;
|
||||
use App\Models\LookupUser;
|
||||
use App\Models\LookupContact;
|
||||
use App\Models\LookupToken;
|
||||
use App\Models\LookupAccountToken;
|
||||
use App\Models\LookupInvitation;
|
||||
|
||||
class InitLookup extends Command
|
||||
@ -123,7 +123,7 @@ class InitLookup extends Command
|
||||
]);
|
||||
}
|
||||
foreach ($account['tokens'] as $token) {
|
||||
LookupToken::create([
|
||||
LookupAccountToken::create([
|
||||
'lookup_account_id' => $lookupAccount->id,
|
||||
'token' => $token['token'],
|
||||
]);
|
||||
|
@ -6,6 +6,7 @@ use Illuminate\Http\Request;
|
||||
use Closure;
|
||||
use App\Models\LookupContact;
|
||||
use App\Models\LookupInvitation;
|
||||
use App\Models\LookupAccountToken;
|
||||
|
||||
class DatabaseLookup
|
||||
{
|
||||
@ -20,7 +21,10 @@ class DatabaseLookup
|
||||
if (! session('SESSION_USER_DB_SERVER')) {
|
||||
return redirect('/logout');
|
||||
}
|
||||
// contacts can login with just the URL
|
||||
} elseif ($guard == 'api') {
|
||||
if ($token = $request->header('X-Ninja-Token')) {
|
||||
LookupAccountToken::setServerByField('token', $token);
|
||||
}
|
||||
} else {
|
||||
if (request()->invitation_key) {
|
||||
LookupInvitation::setServerByField('invitation_key', request()->invitation_key);
|
||||
|
@ -300,7 +300,7 @@ Route::group(['middleware' => ['lookup:user', 'auth:user']], function () {
|
||||
});
|
||||
|
||||
// Route groups for API
|
||||
Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function () {
|
||||
Route::group(['middleware' => ['lookup:api', 'api'], 'prefix' => 'api/v1'], function () {
|
||||
Route::get('ping', 'AccountApiController@ping');
|
||||
Route::post('login', 'AccountApiController@login');
|
||||
Route::post('oauth_login', 'AccountApiController@oauthLogin');
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Models\LookupToken;
|
||||
use App\Models\LookupAccountToken;
|
||||
|
||||
/**
|
||||
* Class AccountToken.
|
||||
@ -43,7 +43,7 @@ class AccountToken extends EntityModel
|
||||
|
||||
AccountToken::creating(function ($token)
|
||||
{
|
||||
LookupToken::createNew($token->account->account_key, [
|
||||
LookupAccountToken::createNew($token->account->account_key, [
|
||||
'token' => $token->token,
|
||||
]);
|
||||
});
|
||||
|
@ -7,7 +7,7 @@ use Eloquent;
|
||||
/**
|
||||
* Class ExpenseCategory.
|
||||
*/
|
||||
class LookupToken extends LookupModel
|
||||
class LookupAccountToken extends LookupModel
|
||||
{
|
||||
/**
|
||||
* @var array
|
@ -45,6 +45,8 @@ class AddMultipleDatabaseSupport extends Migration
|
||||
Schema::table('lookup_tokens', function ($table) {
|
||||
$table->string('token')->change()->unique();
|
||||
});
|
||||
|
||||
Schema::rename('lookup_tokens', 'lookup_account_tokens');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -57,5 +59,7 @@ class AddMultipleDatabaseSupport extends Migration
|
||||
Schema::table('lookup_companies', function ($table) {
|
||||
$table->dropColumn('company_id');
|
||||
});
|
||||
|
||||
Schema::rename('lookup_account_tokens', 'lookup_tokens');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user