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/OTP/OtpTemplateRenderer.php
<?php

declare(strict_types=1);

namespace GhostCompiler\LaravelAuth\OTP;

use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Support\Facades\View;

class OtpTemplateRenderer
{
    /**
     * @param  array<string, mixed>  $context
     */
    public function render(Authenticatable $user, string $channel, string $code, array $context = []): string
    {
        $view = (string) config("laravel-auth.otp_channels.{$channel}.view");
        $ttlSeconds = (int) config('laravel-auth.otp_channels.ttl_seconds', 300);

        return trim(View::make($view, array_replace($context, [
            'user' => $user,
            'channel' => $channel,
            'code' => $code,
            'expiresInMinutes' => max((int) ceil($ttlSeconds / 60), 1),
        ]))->render());
    }
}