mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
ln auth added and email service activated
This commit is contained in:
@@ -10,34 +10,37 @@ use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
||||
|
||||
class LNUrlAuth extends Component
|
||||
{
|
||||
protected ?string $k1 = null;
|
||||
public ?string $k1 = null;
|
||||
protected ?string $url = null;
|
||||
protected ?string $lnurl = null;
|
||||
protected ?string $qrCode = null;
|
||||
|
||||
public function switchToEmail()
|
||||
{
|
||||
dd('test');
|
||||
return to_route('login');
|
||||
}
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->k1 = bin2hex(str()->random(32));
|
||||
$this->lnurl = lnurl\encodeUrl(url('/lnurl-auth-callback',
|
||||
['tag' => 'login', 'k1' => $this->k1, 'action' => 'login']));
|
||||
$this->url = url('/lnurl-auth-callback?tag=login&k1='.$this->k1.'&action=login');
|
||||
$this->lnurl = lnurl\encodeUrl($this->url);
|
||||
$this->qrCode = QrCode::size(300)
|
||||
->generate($this->lnurl);
|
||||
}
|
||||
|
||||
public function checkAuth()
|
||||
{
|
||||
$loginKey = LoginKey::where('k1', $this->k1)
|
||||
->where('created_at', '<=', now()->subMinutes(5))
|
||||
$loginKey = LoginKey::query()
|
||||
->where('k1', $this->k1)
|
||||
->whereDate('created_at', '>=', now()->subMinutes(5))
|
||||
->first();
|
||||
// you should also restrict this 👆🏻 by time, and find only the $k1 that were created in the last 5 minutes
|
||||
|
||||
if ($loginKey) {
|
||||
$user = User::find($loginKey->user_id);
|
||||
auth()->login($user);
|
||||
|
||||
return to_route('welcome');
|
||||
}
|
||||
|
||||
|
||||
@@ -22,16 +22,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
use TwoFactorAuthenticatable;
|
||||
use HasRoles;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
* @var string[]
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'is_lecturer',
|
||||
];
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
|
||||
Reference in New Issue
Block a user