feat : login first

This commit is contained in:
2025-09-26 17:59:26 +08:00
parent 5890122a37
commit 7d09a6028a
7 changed files with 236 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
<?php
/**
* This service file is part of item.
*
* @author ctexthuang
* @contact ctexthuang@qq.com
*/
declare(strict_types=1);
namespace App\Service\Api\Login;
use App\Common\Interface\LoginInterface;
use App\Exception\ErrException;
class PasswordLoginService extends AbstractLoginService implements LoginInterface
{
/**
* @param string $username
* @param string $password
* @return string[]
*/
public function authenticate(string $username, string $password): array
{
if (!$this->validateCredentials([
'username' => $username,
'password' => $password,
])) throw new ErrException('error');
$this->logAttempt($username);
//
return [
'code' => 'success'
];
}
/**
* @param string $type
* @return bool
*/
public function supports(string $type): bool
{
return $type === 'password';
}
}