diff --git a/app/Http/Middleware/ContactKeyLogin.php b/app/Http/Middleware/ContactKeyLogin.php index b339ab90a86d..0fc58c69f8af 100644 --- a/app/Http/Middleware/ContactKeyLogin.php +++ b/app/Http/Middleware/ContactKeyLogin.php @@ -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); } } diff --git a/app/PaymentDrivers/Stripe/ACH.php b/app/PaymentDrivers/Stripe/ACH.php index 703402a34411..a17725225b08 100644 --- a/app/PaymentDrivers/Stripe/ACH.php +++ b/app/PaymentDrivers/Stripe/ACH.php @@ -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();