mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 05:54:36 -04:00
Fixes for random subdomain generator
This commit is contained in:
parent
2f5cc5ac95
commit
0e61a6f491
@ -476,4 +476,62 @@ class LoginController extends BaseController
|
|||||||
->header('X-App-Version', config('ninja.app_version'))
|
->header('X-App-Version', config('ninja.app_version'))
|
||||||
->header('X-Api-Version', config('ninja.minimum_client_version'));
|
->header('X-Api-Version', config('ninja.minimum_client_version'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function redirectToProvider(string $provider)
|
||||||
|
{
|
||||||
|
//'https://www.googleapis.com/auth/gmail.send','email','profile','openid'
|
||||||
|
$scopes = [];
|
||||||
|
|
||||||
|
if($provider == 'google'){
|
||||||
|
$scopes = ['https://www.googleapis.com/auth/gmail.send','email','profile','openid'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request()->has('code')) {
|
||||||
|
return $this->handleProviderCallback($provider);
|
||||||
|
} else {
|
||||||
|
return Socialite::driver($provider)->scopes($scopes)->redirect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handleProviderCallback(string $provider)
|
||||||
|
{
|
||||||
|
$socialite_user = Socialite::driver($provider)
|
||||||
|
->stateless()
|
||||||
|
->user();
|
||||||
|
|
||||||
|
// if($user = OAuth::handleAuth($socialite_user, $provider))
|
||||||
|
// {
|
||||||
|
// Auth::login($user, true);
|
||||||
|
|
||||||
|
// return redirect($this->redirectTo);
|
||||||
|
// }
|
||||||
|
// else if(MultiDB::checkUserEmailExists($socialite_user->getEmail()))
|
||||||
|
// {
|
||||||
|
// Session::flash('error', 'User exists in system, but not with this authentication method'); //todo add translations
|
||||||
|
|
||||||
|
// return view('auth.login');
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// //todo
|
||||||
|
// $name = OAuth::splitName($socialite_user->getName());
|
||||||
|
|
||||||
|
// $new_account = [
|
||||||
|
// 'first_name' => $name[0],
|
||||||
|
// 'last_name' => $name[1],
|
||||||
|
// 'password' => '',
|
||||||
|
// 'email' => $socialite_user->getEmail(),
|
||||||
|
// 'oauth_user_id' => $socialite_user->getId(),
|
||||||
|
// 'oauth_provider_id' => $provider
|
||||||
|
// ];
|
||||||
|
|
||||||
|
// $account = CreateAccount::dispatchNow($new_account);
|
||||||
|
|
||||||
|
// Auth::login($account->default_company->owner(), true);
|
||||||
|
|
||||||
|
// $cookie = cookie('db', $account->default_company->db);
|
||||||
|
|
||||||
|
// return redirect($this->redirectTo)->withCookie($cookie);
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ class BaseController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function notFoundClient()
|
public function notFoundClient()
|
||||||
{
|
{
|
||||||
return abort(404);
|
abort(404, 'Page not found in client portal.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,7 +68,7 @@ class DocumentController extends Controller
|
|||||||
|
|
||||||
$documents->map(function ($document) {
|
$documents->map(function ($document) {
|
||||||
if (auth()->user('contact')->client->id != $document->documentable->id) {
|
if (auth()->user('contact')->client->id != $document->documentable->id) {
|
||||||
abort(401);
|
abort(401, 'Permission denied');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class EntityViewController extends Controller
|
|||||||
public function index(string $entity_type, string $invitation_key)
|
public function index(string $entity_type, string $invitation_key)
|
||||||
{
|
{
|
||||||
if (! in_array($entity_type, $this->entity_types)) {
|
if (! in_array($entity_type, $this->entity_types)) {
|
||||||
abort(404);
|
abort(404, 'Entity not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$invitation_entity = sprintf('App\\Models\\%sInvitation', ucfirst($entity_type));
|
$invitation_entity = sprintf('App\\Models\\%sInvitation', ucfirst($entity_type));
|
||||||
@ -91,7 +91,7 @@ class EntityViewController extends Controller
|
|||||||
public function handlePassword(string $entity_type, string $invitation_key)
|
public function handlePassword(string $entity_type, string $invitation_key)
|
||||||
{
|
{
|
||||||
if (! in_array($entity_type, $this->entity_types)) {
|
if (! in_array($entity_type, $this->entity_types)) {
|
||||||
abort(404);
|
abort(404, 'Entity not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$invitation_entity = sprintf('App\\Models\\%sInvitation', ucfirst($entity_type));
|
$invitation_entity = sprintf('App\\Models\\%sInvitation', ucfirst($entity_type));
|
||||||
|
@ -149,6 +149,6 @@ class PaymentMethodController extends Controller
|
|||||||
return $gateway = auth()->user()->client->getBankTransferGateway();
|
return $gateway = auth()->user()->client->getBankTransferGateway();
|
||||||
}
|
}
|
||||||
|
|
||||||
return abort(404);
|
abort(404, 'Gateway not found.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,11 +93,16 @@ class LoginController extends BaseController
|
|||||||
public function redirectToProvider(string $provider)
|
public function redirectToProvider(string $provider)
|
||||||
{
|
{
|
||||||
//'https://www.googleapis.com/auth/gmail.send','email','profile','openid'
|
//'https://www.googleapis.com/auth/gmail.send','email','profile','openid'
|
||||||
//
|
$scopes = [];
|
||||||
|
|
||||||
|
if($provider == 'google'){
|
||||||
|
$scopes = ['https://www.googleapis.com/auth/gmail.send','email','profile','openid'];
|
||||||
|
}
|
||||||
|
|
||||||
if (request()->has('code')) {
|
if (request()->has('code')) {
|
||||||
return $this->handleProviderCallback($provider);
|
return $this->handleProviderCallback($provider);
|
||||||
} else {
|
} else {
|
||||||
return Socialite::driver($provider)->scopes()->redirect();
|
return Socialite::driver($provider)->scopes($scopes)->redirect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,43 +236,5 @@ class LoginController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Received the returning object from the provider
|
|
||||||
* which we will use to resolve the user, we return the response in JSON format
|
|
||||||
*
|
|
||||||
* @return json
|
|
||||||
|
|
||||||
public function handleProviderCallbackApiUser(string $provider)
|
|
||||||
{
|
|
||||||
$socialite_user = Socialite::driver($provider)->stateless()->user();
|
|
||||||
|
|
||||||
if($user = OAuth::handleAuth($socialite_user, $provider))
|
|
||||||
{
|
|
||||||
return $this->itemResponse($user);
|
|
||||||
}
|
|
||||||
else if(MultiDB::checkUserEmailExists($socialite_user->getEmail()))
|
|
||||||
{
|
|
||||||
|
|
||||||
return $this->errorResponse(['message'=>'User exists in system, but not with this authentication method'], 400);
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//todo
|
|
||||||
$name = OAuth::splitName($socialite_user->getName());
|
|
||||||
|
|
||||||
$new_account = [
|
|
||||||
'first_name' => $name[0],
|
|
||||||
'last_name' => $name[1],
|
|
||||||
'password' => '',
|
|
||||||
'email' => $socialite_user->getEmail(),
|
|
||||||
];
|
|
||||||
|
|
||||||
$account = CreateAccount::dispatchNow($new_account);
|
|
||||||
|
|
||||||
return $this->itemResponse($account->default_company->owner());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
@ -643,18 +643,12 @@ class TaskController extends BaseController
|
|||||||
|
|
||||||
$sort_status_id = $this->decodePrimaryKey($key);
|
$sort_status_id = $this->decodePrimaryKey($key);
|
||||||
|
|
||||||
// nlog($task_list);
|
|
||||||
|
|
||||||
foreach ($task_list as $key => $task)
|
foreach ($task_list as $key => $task)
|
||||||
{
|
{
|
||||||
|
|
||||||
// nlog($task);
|
|
||||||
|
|
||||||
$task_record = Task::where('id', $this->decodePrimaryKey($task))
|
$task_record = Task::where('id', $this->decodePrimaryKey($task))
|
||||||
->where('company_id', auth()->user()->company()->id)
|
->where('company_id', auth()->user()->company()->id)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
// nlog($task_record->id);
|
|
||||||
|
|
||||||
$task_record->status_order = $key;
|
$task_record->status_order = $key;
|
||||||
$task_record->status_id = $sort_status_id;
|
$task_record->status_id = $sort_status_id;
|
||||||
@ -663,6 +657,6 @@ class TaskController extends BaseController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json(['message' => 'Ok'],200);
|
return response()->json(['message' => 'Ok'], 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,6 @@ class ContactRegister
|
|||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
return abort(404);
|
abort(404, 'ContactRegister Middlware');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,6 @@ class RegisterRequest extends FormRequest
|
|||||||
return $company;
|
return $company;
|
||||||
}
|
}
|
||||||
|
|
||||||
abort(404);
|
abort(404, 'Register request not found.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,9 @@
|
|||||||
namespace App\Jobs\Company;
|
namespace App\Jobs\Company;
|
||||||
|
|
||||||
use App\DataMapper\CompanySettings;
|
use App\DataMapper\CompanySettings;
|
||||||
|
use App\Libraries\MultiDB;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
|
use App\Utils\Ninja;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@ -60,6 +62,12 @@ class CreateCompany
|
|||||||
$company->subdomain = isset($this->request['subdomain']) ? $this->request['subdomain'] : '';
|
$company->subdomain = isset($this->request['subdomain']) ? $this->request['subdomain'] : '';
|
||||||
$company->custom_fields = new \stdClass;
|
$company->custom_fields = new \stdClass;
|
||||||
$company->default_password_timeout = 1800000;
|
$company->default_password_timeout = 1800000;
|
||||||
|
|
||||||
|
if(Ninja::isHosted())
|
||||||
|
$company->subdomain = MultiDB::randomSubdomainGenerator();
|
||||||
|
else
|
||||||
|
$company->subdomain = '';
|
||||||
|
|
||||||
$company->save();
|
$company->save();
|
||||||
|
|
||||||
return $company;
|
return $company;
|
||||||
|
@ -45,7 +45,7 @@ class VendorUpdatedActivity implements ShouldQueue
|
|||||||
|
|
||||||
$fields = new stdClass;
|
$fields = new stdClass;
|
||||||
|
|
||||||
$user_id = array_key_exists('user_id', $event->event_vars) ? $event->event_vars['user_id'] : $event->vendor->user_id;
|
$user_id = array_key_exists('user_id', $event->event_vars) ? $event->event_vars['user_id'] : $event->vendor->user_id;
|
||||||
|
|
||||||
$fields->vendor_id = $vendor->id;
|
$fields->vendor_id = $vendor->id;
|
||||||
$fields->user_id = $user_id;
|
$fields->user_id = $user_id;
|
||||||
|
@ -24,7 +24,7 @@ Route::post('password/reset', 'Auth\ResetPasswordController@reset')->middleware(
|
|||||||
* Social authentication
|
* Social authentication
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Route::get('auth/{provider}', 'Auth\LoginController@redirectToProvider');
|
Route::get('auth/{provider}', 'Auth\LoginController@redirectToProvider');
|
||||||
// Route::get('auth/{provider}/create', 'Auth\LoginController@redirectToProviderAndCreate');
|
// Route::get('auth/{provider}/create', 'Auth\LoginController@redirectToProviderAndCreate');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user