1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 22:54:25 +01:00

Multi-db support

This commit is contained in:
Hillel Coren 2017-05-01 18:25:18 +03:00
parent b6242d9981
commit 80c6d68647
3 changed files with 16 additions and 7 deletions

View File

@ -37,6 +37,8 @@ class DatabaseLookup
} }
} elseif ($guard == 'postmark') { } elseif ($guard == 'postmark') {
LookupInvitation::setServerByField('message_id', request()->MessageID); LookupInvitation::setServerByField('message_id', request()->MessageID);
} elseif ($guard == 'license') {
config(['database.default' => DB_NINJA_1]);
} }
return $next($request); return $next($request);

View File

@ -62,9 +62,11 @@ Route::group(['middleware' => ['lookup:contact', 'auth:client']], function () {
Route::get('api/client.activity', ['as' => 'api.client.activity', 'uses' => 'ClientPortalController@activityDatatable']); Route::get('api/client.activity', ['as' => 'api.client.activity', 'uses' => 'ClientPortalController@activityDatatable']);
}); });
Route::group(['middleware' => 'lookup:license'], function () {
Route::get('license', 'NinjaController@show_license_payment'); Route::get('license', 'NinjaController@show_license_payment');
Route::post('license', 'NinjaController@do_license_payment'); Route::post('license', 'NinjaController@do_license_payment');
Route::get('claim_license', 'NinjaController@claim_license'); Route::get('claim_license', 'NinjaController@claim_license');
});
Route::post('signup/validate', 'AccountController@checkEmail'); Route::post('signup/validate', 'AccountController@checkEmail');
Route::post('signup/submit', 'AccountController@submitSignup'); Route::post('signup/submit', 'AccountController@submitSignup');
@ -91,6 +93,7 @@ Route::get('/login', ['as' => 'login', 'uses' => 'Auth\AuthController@getLoginWr
Route::get('/logout', ['as' => 'logout', 'uses' => 'Auth\AuthController@getLogoutWrapper']); Route::get('/logout', ['as' => 'logout', 'uses' => 'Auth\AuthController@getLogoutWrapper']);
Route::get('/recover_password', ['as' => 'forgot', 'uses' => 'Auth\PasswordController@getEmail']); Route::get('/recover_password', ['as' => 'forgot', 'uses' => 'Auth\PasswordController@getEmail']);
Route::get('/password/reset/{token}', ['as' => 'forgot', 'uses' => 'Auth\PasswordController@getReset']); Route::get('/password/reset/{token}', ['as' => 'forgot', 'uses' => 'Auth\PasswordController@getReset']);
Route::group(['middleware' => ['lookup:user']], function () { Route::group(['middleware' => ['lookup:user']], function () {
Route::get('/user/confirm/{confirmation_code}', 'UserController@confirm'); Route::get('/user/confirm/{confirmation_code}', 'UserController@confirm');
Route::post('/login', ['as' => 'login', 'uses' => 'Auth\AuthController@postLoginWrapper']); Route::post('/login', ['as' => 'login', 'uses' => 'Auth\AuthController@postLoginWrapper']);
@ -104,6 +107,7 @@ Route::get('/client/logout', ['as' => 'logout', 'uses' => 'ClientAuth\AuthContro
Route::get('/client/sessionexpired', ['as' => 'logout', 'uses' => 'ClientAuth\AuthController@getSessionExpired']); Route::get('/client/sessionexpired', ['as' => 'logout', 'uses' => 'ClientAuth\AuthController@getSessionExpired']);
Route::get('/client/recover_password', ['as' => 'forgot', 'uses' => 'ClientAuth\PasswordController@getEmail']); Route::get('/client/recover_password', ['as' => 'forgot', 'uses' => 'ClientAuth\PasswordController@getEmail']);
Route::get('/client/password/reset/{token}', ['as' => 'forgot', 'uses' => 'ClientAuth\PasswordController@getReset']); Route::get('/client/password/reset/{token}', ['as' => 'forgot', 'uses' => 'ClientAuth\PasswordController@getReset']);
Route::group(['middleware' => ['lookup:contact']], function () { Route::group(['middleware' => ['lookup:contact']], function () {
Route::post('/client/login', ['as' => 'login', 'uses' => 'ClientAuth\AuthController@postLogin']); Route::post('/client/login', ['as' => 'login', 'uses' => 'ClientAuth\AuthController@postLogin']);
Route::post('/client/recover_password', ['as' => 'forgot', 'uses' => 'ClientAuth\PasswordController@postEmail']); Route::post('/client/recover_password', ['as' => 'forgot', 'uses' => 'ClientAuth\PasswordController@postEmail']);

View File

@ -4,6 +4,7 @@ namespace App\Services;
use App\Events\UserLoggedIn; use App\Events\UserLoggedIn;
use App\Ninja\Repositories\AccountRepository; use App\Ninja\Repositories\AccountRepository;
use App\Models\LookupUser;
use Auth; use Auth;
use Input; use Input;
use Session; use Session;
@ -59,13 +60,13 @@ class AuthService
$socialiteUser = Socialite::driver($provider)->user(); $socialiteUser = Socialite::driver($provider)->user();
$providerId = self::getProviderId($provider); $providerId = self::getProviderId($provider);
if (Auth::check()) {
$user = Auth::user();
$isRegistered = $user->registered;
$email = $socialiteUser->email; $email = $socialiteUser->email;
$oauthUserId = $socialiteUser->id; $oauthUserId = $socialiteUser->id;
$name = Utils::splitName($socialiteUser->name); $name = Utils::splitName($socialiteUser->name);
if (Auth::check()) {
$user = Auth::user();
$isRegistered = $user->registered;
$result = $this->accountRepo->updateUserFromOauth($user, $name[0], $name[1], $email, $providerId, $oauthUserId); $result = $this->accountRepo->updateUserFromOauth($user, $name[0], $name[1], $email, $providerId, $oauthUserId);
if ($result === true) { if ($result === true) {
@ -81,6 +82,8 @@ class AuthService
Session::flash('error', $result); Session::flash('error', $result);
} }
} else { } else {
LookupUser::setServerByField('email', $email);
if ($user = $this->accountRepo->findUserByOauth($providerId, $socialiteUser->id)) { if ($user = $this->accountRepo->findUserByOauth($providerId, $socialiteUser->id)) {
Auth::login($user, true); Auth::login($user, true);
event(new UserLoggedIn()); event(new UserLoggedIn());