1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #5964 from turbo124/v5-develop

Fixes for client portal links
This commit is contained in:
David Bomba 2021-06-08 21:45:37 +10:00 committed by GitHub
commit b8365d94f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 11 deletions

View File

@ -55,18 +55,21 @@ class InvitationController extends Controller
->firstOrFail();
/* Return early if we have the correct client_hash embedded */
$client_contact = $invitation->contact;
if(empty($client_contact->email))
$client_contact->email = Str::random(15) . "@example.com"; $client_contact->save();
if (request()->has('client_hash') && request()->input('client_hash') == $invitation->contact->client->client_hash) {
auth()->guard('contact')->loginUsingId($invitation->contact->id, true);
auth()->guard('contact')->login($client_contact, true);
} elseif ((bool) $invitation->contact->client->getSetting('enable_client_portal_password') !== false) {
//If no contact password is set - this will cause a 401 error - instead redirect to the client.login route
$this->middleware('auth:contact');
return redirect()->route('client.login');
} else {
auth()->guard('contact')->loginUsingId($invitation->contact->id, true);
nlog("else - default - login contact");
auth()->guard('contact')->login($client_contact, true);
}

View File

@ -46,7 +46,7 @@ class ContactKeyLogin
if($client_contact = ClientContact::where('email', $contact_email)->where('company_id', $payload['company_id'])->first()){
if(empty($client_contact->email))
$client_contact->email = Str::random(6) . "@example.com"; $client_contact->save();
$client_contact->email = Str::random(15) . "@example.com"; $client_contact->save();
auth()->guard('contact')->login($client_contact, true);

View File

@ -212,12 +212,12 @@ class CompanyImport implements ShouldQueue
if(count($backup_users) > 1){
$this->message = 'Only one user can be in the import for a Free Account';
$this->pre_flight_checks_pass = false;
$this->pre_flight_checks_pass = false;
}
if(count($backup_users) == 1 && $company_owner->email != $backup_users[0]->email) {
$this->message = 'Account emails do not match. Account owner email must match backup user email';
$this->pre_flight_checks_pass = false;
$this->pre_flight_checks_pass = false;
}
$backup_users_emails = array_column($backup_users, 'email');
@ -230,7 +230,7 @@ class CompanyImport implements ShouldQueue
if($this->account->plan == 'pro'){
$this->message = 'Pro plan is limited to one user, you have multiple users in the backup file';
$this->pre_flight_checks_pass = false;
$this->pre_flight_checks_pass = false;
}
if($this->account->plan == 'enterprise'){
@ -241,7 +241,7 @@ class CompanyImport implements ShouldQueue
if($total_import_users > $account_plan_num_user){
$this->message = "Total user count ({$total_import_users}) greater than your plan allows ({$account_plan_num_user})";
$this->pre_flight_checks_pass = false;
$this->pre_flight_checks_pass = false;
}
}
@ -255,12 +255,15 @@ class CompanyImport implements ShouldQueue
$this->message = "You are attempting to import ({$client_count}) clients, your current plan allows a total of ({$client_limit})";
$this->pre_flight_checks_pass = false;
$this->pre_flight_checks_pass = false;
}
}
nlog($this->message);
nlog($this->pre_flight_checks_pass);
return $this;
}
@ -278,7 +281,7 @@ class CompanyImport implements ShouldQueue
//perform some magic here
}
if(!$this->pre_flight_checks_pass)
if($this->pre_flight_checks_pass === false)
{
$nmo = new NinjaMailerObject;
$nmo->mailable = new CompanyImportFailure($this->company, $this->message);

View File

@ -15,6 +15,7 @@ use App\Models\Account;
use App\Models\Company;
use App\Models\CompanyUser;
use App\Models\User;
use App\Utils\Ninja;
use App\Utils\Traits\MakesHash;
/**