1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Multi-db fixes

This commit is contained in:
Hillel Coren 2017-05-10 12:42:15 +03:00
parent 715eced0de
commit fec7f6ad9b
3 changed files with 16 additions and 6 deletions

View File

@ -22,13 +22,13 @@ class DatabaseLookup
if ($guard == 'user') {
if ($code = $request->confirmation_code) {
LookupUser::setServerByField('confirmation_code', $code);
} elseif ($server = session(SESSION_DB_SERVER)) {
config(['database.default' => $server]);
$user = Auth::user()->fresh();
$user->load('account');
Auth::setUser($user);
} elseif ($email = $request->email) {
} elseif (session(SESSION_DB_SERVER)) {
// do nothing
} elseif (! Auth::check() && $email = $request->email) {
LookupUser::setServerByField('email', $email);
} else {
Auth::logout();
return redirect('/login');
}
} elseif ($guard == 'api') {
if ($token = $request->header('X-Ninja-Token')) {
@ -41,6 +41,9 @@ class DatabaseLookup
LookupInvitation::setServerByField('invitation_key', $key);
} elseif ($key = request()->contact_key ?: session('contact_key')) {
LookupContact::setServerByField('contact_key', $key);
} else {
Auth::logout();
return redirect('/client/sessionexpired');
}
} elseif ($guard == 'postmark') {
LookupInvitation::setServerByField('message_id', request()->MessageID);

View File

@ -66,6 +66,12 @@ class StartupCheck
}
}
if (env('MULTI_DB_ENABLED')) {
if ($server = session(SESSION_DB_SERVER)) {
config(['database.default' => $server]);
}
}
// Check the application is up to date and for any news feed messages
if (Auth::check()) {
$count = Session::get(SESSION_COUNTER, 0);

View File

@ -55,5 +55,6 @@ class HandleUserSignedUp
}
session([SESSION_COUNTER => -1]);
session([SESSION_DB_SERVER => config('database.default')]);
}
}