TRF Certest first commit

This commit is contained in:
2025-02-26 08:57:46 +01:00
commit 3ce064a108
2524 changed files with 475404 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
<?php
namespace Vanguard\Http\Requests\Auth;
use Illuminate\Contracts\Validation\Factory as ValidationFactory;
use Vanguard\Http\Requests\Request;
class LoginRequest extends Request
{
public function rules(): array
{
return [
'username' => 'required',
'password' => 'required',
];
}
public function getCredentials(): array
{
// The form field for providing username or password
// have name of "username", however, in order to support
// logging users in with both (username and email)
// we have to check if user has entered one or another
$username = $this->get('username');
if ($this->isEmail($username)) {
return [
'email' => $username,
'password' => $this->get('password'),
];
}
return $this->only('username', 'password');
}
private function isEmail($param): bool
{
$factory = $this->container->make(ValidationFactory::class);
return ! $factory->make(
['username' => $param],
['username' => 'email']
)->fails();
}
}