<?php

namespace App\Http\Requests\User;

use App\Rules\User\Google2FaSecretKeyVerificationRule;
use App\Services\Google2FaServices;
use Illuminate\Foundation\Http\FormRequest;

class CheckGoogle2FaRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */

     protected Google2FaServices $google2FaServices;

     public function __construct(Google2FaServices $google2FaServices)
     {
        $this->google2FaServices = $google2FaServices;
     }

    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'secret' => ['required', new Google2FaSecretKeyVerificationRule($this->google2FaServices, session()->get('f2'))] 
        ];
    }
}
