mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Multi-db support
This commit is contained in:
parent
b6242d9981
commit
80c6d68647
@ -37,6 +37,8 @@ class DatabaseLookup
|
||||
}
|
||||
} elseif ($guard == 'postmark') {
|
||||
LookupInvitation::setServerByField('message_id', request()->MessageID);
|
||||
} elseif ($guard == 'license') {
|
||||
config(['database.default' => DB_NINJA_1]);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
@ -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('license', 'NinjaController@show_license_payment');
|
||||
Route::post('license', 'NinjaController@do_license_payment');
|
||||
Route::get('claim_license', 'NinjaController@claim_license');
|
||||
Route::group(['middleware' => 'lookup:license'], function () {
|
||||
Route::get('license', 'NinjaController@show_license_payment');
|
||||
Route::post('license', 'NinjaController@do_license_payment');
|
||||
Route::get('claim_license', 'NinjaController@claim_license');
|
||||
});
|
||||
|
||||
Route::post('signup/validate', 'AccountController@checkEmail');
|
||||
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('/recover_password', ['as' => 'forgot', 'uses' => 'Auth\PasswordController@getEmail']);
|
||||
Route::get('/password/reset/{token}', ['as' => 'forgot', 'uses' => 'Auth\PasswordController@getReset']);
|
||||
|
||||
Route::group(['middleware' => ['lookup:user']], function () {
|
||||
Route::get('/user/confirm/{confirmation_code}', 'UserController@confirm');
|
||||
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/recover_password', ['as' => 'forgot', 'uses' => 'ClientAuth\PasswordController@getEmail']);
|
||||
Route::get('/client/password/reset/{token}', ['as' => 'forgot', 'uses' => 'ClientAuth\PasswordController@getReset']);
|
||||
|
||||
Route::group(['middleware' => ['lookup:contact']], function () {
|
||||
Route::post('/client/login', ['as' => 'login', 'uses' => 'ClientAuth\AuthController@postLogin']);
|
||||
Route::post('/client/recover_password', ['as' => 'forgot', 'uses' => 'ClientAuth\PasswordController@postEmail']);
|
||||
|
@ -4,6 +4,7 @@ namespace App\Services;
|
||||
|
||||
use App\Events\UserLoggedIn;
|
||||
use App\Ninja\Repositories\AccountRepository;
|
||||
use App\Models\LookupUser;
|
||||
use Auth;
|
||||
use Input;
|
||||
use Session;
|
||||
@ -59,13 +60,13 @@ class AuthService
|
||||
$socialiteUser = Socialite::driver($provider)->user();
|
||||
$providerId = self::getProviderId($provider);
|
||||
|
||||
$email = $socialiteUser->email;
|
||||
$oauthUserId = $socialiteUser->id;
|
||||
$name = Utils::splitName($socialiteUser->name);
|
||||
|
||||
if (Auth::check()) {
|
||||
$user = Auth::user();
|
||||
$isRegistered = $user->registered;
|
||||
|
||||
$email = $socialiteUser->email;
|
||||
$oauthUserId = $socialiteUser->id;
|
||||
$name = Utils::splitName($socialiteUser->name);
|
||||
$result = $this->accountRepo->updateUserFromOauth($user, $name[0], $name[1], $email, $providerId, $oauthUserId);
|
||||
|
||||
if ($result === true) {
|
||||
@ -81,6 +82,8 @@ class AuthService
|
||||
Session::flash('error', $result);
|
||||
}
|
||||
} else {
|
||||
LookupUser::setServerByField('email', $email);
|
||||
|
||||
if ($user = $this->accountRepo->findUserByOauth($providerId, $socialiteUser->id)) {
|
||||
Auth::login($user, true);
|
||||
event(new UserLoggedIn());
|
||||
|
Loading…
Reference in New Issue
Block a user