1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 22:54:25 +01:00
invoiceninja/app/Utils/ClientPortal/MagicLink.php

35 lines
859 B
PHP
Raw Normal View History

2021-03-31 02:07:54 +02:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2023-01-28 23:21:40 +01:00
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
2021-03-31 02:07:54 +02:00
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2021-03-31 02:07:54 +02:00
*/
namespace App\Utils\ClientPortal;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
class MagicLink
{
//return a magic login link URL
2021-06-03 01:50:31 +02:00
public static function create($email, $company_id, $url = null) :string
2021-03-31 02:07:54 +02:00
{
$magic_key = Str::random(64);
$timeout = 600; //seconds
2021-06-03 01:50:31 +02:00
$payload = [
'email' => $email,
'company_id' => $company_id,
2021-06-03 01:50:31 +02:00
];
Cache::add($magic_key, $payload, $timeout);
2021-03-31 02:07:54 +02:00
2021-03-31 18:10:44 +02:00
return route('client.contact_magic_link', ['magic_link' => $magic_key, 'redirect' => $url]);
2021-03-31 02:07:54 +02:00
}
}