Merge pull request #6438 from beganovich/v5-617

(v5) Auto-login on ACH verification email
This commit is contained in:
Benjamin Beganović 2021-08-10 14:16:01 +02:00 committed by GitHub
commit 728d077a94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View File

@ -71,11 +71,16 @@ class ContactKeyLogin
}
} elseif ($request->segment(2) && $request->segment(2) == 'key_login' && $request->segment(3)) {
if ($client_contact = ClientContact::where('contact_key', $request->segment(3))->first()) {
if(empty($client_contact->email))
if(empty($client_contact->email)) {
$client_contact->email = Str::random(6) . "@example.com"; $client_contact->save();
}
auth()->guard('contact')->login($client_contact, true);
if ($request->query('next')) {
return redirect($request->query('next'));
}
return redirect()->to('client/dashboard');
}
} elseif ($request->has('client_hash') && config('ninja.db.multi_db_enabled')) {
@ -106,7 +111,6 @@ class ContactKeyLogin
}
}
return $next($request);
}
}

View File

@ -68,8 +68,15 @@ class ACH
$client_gateway_token = $this->storePaymentMethod($source, $request->input('method'), $customer);
$verification = route('client.payment_methods.verification', ['payment_method' => $client_gateway_token->hashed_id, 'method' => GatewayType::BANK_TRANSFER], false);
$mailer = new NinjaMailerObject();
$mailer->mailable = new ACHVerificationNotification(auth('contact')->user()->client->company, route('client.payment_methods.verification', ['payment_method' => $client_gateway_token->hashed_id, 'method' => GatewayType::BANK_TRANSFER]));
$mailer->mailable = new ACHVerificationNotification(
auth('contact')->user()->client->company,
route('client.contact_login', ['contact_key' => auth('contact')->user()->contact_key, 'next' => $verification])
);
$mailer->company = auth('contact')->user()->client->company;
$mailer->settings = auth('contact')->user()->client->company->settings;
$mailer->to_user = auth('contact')->user();