Laravel Auth

PHP MIT

Laravel Auth by GhostCompiler adds advanced authentication for Laravel with TOTP 2FA, passkeys via WebAuthn, OTP channels (email, SMS, WhatsApp), trusted devices, and tenant-aware social login.

Stars
2
Forks
0
Downloads
N/A
Open Issues
0
Files main

Repository Files

Loading file structure...
src/Support/VerifiedFactor.php
<?php

declare(strict_types=1);

namespace GhostCompiler\LaravelAuth\Support;

use Illuminate\Contracts\Auth\Authenticatable;
use RuntimeException;

final readonly class VerifiedFactor
{
    public function __construct(
        public string $type,
        public string $userId,
        public int $verifiedAt
    ) {}

    public static function issue(Authenticatable $user, string $type): self
    {
        return new self(
            $type,
            (string) $user->getAuthIdentifier(),
            now()->timestamp
        );
    }

    public function assertMatches(Authenticatable $user): void
    {
        if ($this->userId !== (string) $user->getAuthIdentifier()) {
            throw new RuntimeException('Invalid verification proof.');
        }
    }
}