2FAuth/app/Api/v1/Requests/TwoFAccountDynamicRequest.php

50 lines
1.0 KiB
PHP
Raw Normal View History

<?php
namespace App\Api\v1\Requests;
use Illuminate\Foundation\Http\FormRequest;
2022-11-22 15:15:52 +01:00
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Auth;
class TwoFAccountDynamicRequest extends FormRequest
{
/**
2022-11-22 15:15:52 +01:00
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return Auth::check();
}
2022-11-22 15:15:52 +01:00
/**
2022-11-22 15:15:52 +01:00
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = Arr::has($this->validationData(), 'uri')
? (new TwoFAccountUriRequest)->rules()
: (new TwoFAccountStoreRequest)->rules();
return $rules;
}
/**
* Prepare the data for validation.
*
2022-12-09 10:52:17 +01:00
* @codeCoverageIgnore
*
* @return void
*/
protected function prepareForValidation()
{
$this->merge([
2022-11-22 15:15:52 +01:00
'otp_type' => strtolower($this->otp_type),
'algorithm' => strtolower($this->algorithm),
]);
}
2022-11-22 15:15:52 +01:00
}