1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00

Multi-db fixes

This commit is contained in:
Hillel Coren 2017-05-10 11:15:58 +03:00
parent a488d6a40f
commit 1e018f1ba9
3 changed files with 5 additions and 4 deletions

View File

@ -261,6 +261,7 @@ class UserController extends BaseController
if ($user->public_id) {
Auth::logout();
Session::flush();
$token = Password::getRepository()->create($user);
return Redirect::to("/password/reset/{$token}");

View File

@ -20,15 +20,15 @@ class DatabaseLookup
}
if ($guard == 'user') {
if (Auth::check() && $server = session(SESSION_DB_SERVER)) {
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) {
LookupUser::setServerByField('email', $email);
} elseif ($code = $request->confirmation_code) {
LookupUser::setServerByField('confirmation_code', $code);
}
} elseif ($guard == 'api') {
if ($token = $request->header('X-Ninja-Token')) {

View File

@ -66,7 +66,7 @@ class LookupModel extends Eloquent
$className = get_called_class();
$className = str_replace('Lookup', '', $className);
$key = sprintf('server:%s:%s:%s', $className, $field, $value);
$isUser = $className == 'App\Models\User';
$isUser = ($className == 'App\Models\User' && $field == 'email');
// check if we've cached this lookup
if (env('MULTI_DB_CACHE_ENABLED') && $server = Cache::get($key)) {