mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
commit
1f6787e2f3
@ -26,4 +26,9 @@ class ContactHashLoginController extends Controller
|
||||
{
|
||||
return redirect('/client/login');
|
||||
}
|
||||
|
||||
public function magicLink(string $magic_link)
|
||||
{
|
||||
return redirect('/client/login');
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ use App\Models\ClientContact;
|
||||
use Auth;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class ContactKeyLogin
|
||||
{
|
||||
@ -36,31 +37,49 @@ class ContactKeyLogin
|
||||
if (Auth::guard('contact')->check()) {
|
||||
Auth::guard('contact')->logout();
|
||||
}
|
||||
nlog("merp");
|
||||
nlog($request->has('magic_link'));
|
||||
nlog($request->input('magic_link'));
|
||||
nlog($request->all());
|
||||
|
||||
if ($request->segment(3) && config('ninja.db.multi_db_enabled')) {
|
||||
if (MultiDB::findAndSetDbByContactKey($request->segment(3))) {
|
||||
$client_contact = ClientContact::where('contact_key', $request->segment(3))->first();
|
||||
Auth::guard('contact')->login($client_contact, true);
|
||||
|
||||
if($client_contact = ClientContact::where('contact_key', $request->segment(3))->first()){
|
||||
auth()->guard('contact')->login($client_contact, true);
|
||||
return redirect()->to('client/dashboard');
|
||||
}
|
||||
|
||||
}
|
||||
} elseif ($request->has('contact_key')) {
|
||||
} elseif ($request->segment(2) && $request->segment(2) == 'key_login' && $request->segment(3)) {
|
||||
if ($client_contact = ClientContact::where('contact_key', $request->segment(3))->first()) {
|
||||
Auth::guard('contact')->login($client_contact, true);
|
||||
auth()->guard('contact')->login($client_contact, true);
|
||||
return redirect()->to('client/dashboard');
|
||||
}
|
||||
} elseif ($request->has('client_hash') && config('ninja.db.multi_db_enabled')) {
|
||||
if (MultiDB::findAndSetDbByClientHash($request->input('client_hash'))) {
|
||||
$client = Client::where('client_hash', $request->input('client_hash'))->first();
|
||||
Auth::guard('contact')->login($client->primary_contact()->first(), true);
|
||||
return redirect()->to('client/dashboard');
|
||||
|
||||
if($client = Client::where('client_hash', $request->input('client_hash'))->first()){
|
||||
auth()->guard('contact')->login($client->primary_contact()->first(), true);
|
||||
return redirect()->to('client/dashboard');
|
||||
}
|
||||
}
|
||||
} elseif ($request->has('client_hash')) {
|
||||
if ($client = Client::where('client_hash', $request->input('client_hash'))->first()) {
|
||||
Auth::guard('contact')->login($client->primary_contact()->first(), true);
|
||||
return redirect()->to('client/dashboard');
|
||||
}
|
||||
} elseif ($request->segment(2) && $request->segment(2) == 'magic_link' && $request->segment(3)) {
|
||||
$contact_email = Cache::get($request->segment(3));
|
||||
nlog("double merp");
|
||||
if($client_contact = ClientContact::where('email', $contact_email)->first()){
|
||||
Auth::guard('contact')->login($client_contact, true);
|
||||
return redirect()->to('client/dashboard');
|
||||
}
|
||||
}
|
||||
|
||||
nlog("exit");
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class SubscriptionTransformer extends EntityTransformer
|
||||
'promo_discount' => (float)$subscription->promo_discount,
|
||||
'is_amount_discount' => (bool)$subscription->is_amount_discount,
|
||||
'allow_cancellation' => (bool)$subscription->allow_cancellation,
|
||||
'per_seat_enabled' => (bool)$subscription->per_set_enabled,
|
||||
'per_seat_enabled' => (bool)$subscription->per_seat_enabled,
|
||||
'min_seats_limit' => (int)$subscription->min_seats_limit,
|
||||
'max_seats_limit' => (int)$subscription->max_seats_limit,
|
||||
'trial_enabled' => (bool)$subscription->trial_enabled,
|
||||
|
30
app/Utils/ClientPortal/MagicLink.php
Normal file
30
app/Utils/ClientPortal/MagicLink.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Utils\ClientPortal;
|
||||
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class MagicLink
|
||||
{
|
||||
|
||||
//return a magic login link URL
|
||||
public static function create($email) :string
|
||||
{
|
||||
$magic_key = Str::random(64);
|
||||
$timeout = 600; //seconds
|
||||
|
||||
Cache::add($magic_key, $email, $timeout);
|
||||
|
||||
return route('client.contact_magic_link', ['magic_link' => $magic_key]);
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ Route::post('view/{entity_type}/{invitation_key}/password', 'ClientPortal\Entity
|
||||
Route::get('tmp_pdf/{hash}', 'ClientPortal\TempRouteController@index')->name('tmp_pdf');
|
||||
|
||||
Route::get('client/key_login/{contact_key}', 'ClientPortal\ContactHashLoginController@login')->name('client.contact_login')->middleware(['contact_key_login']);
|
||||
Route::get('client/magic_link/{magic_link}', 'ClientPortal\ContactHashLoginController@magicLink')->name('client.contact_magic_link')->middleware(['contact_key_login']);
|
||||
Route::get('documents/{document_hash}', 'ClientPortal\DocumentController@publicDownload')->name('documents.public_download');
|
||||
|
||||
//todo implement domain DB
|
||||
|
Loading…
Reference in New Issue
Block a user