mirror of
https://gitee.com/ctexthuang/hyperf-micro-svc.git
synced 2026-02-08 10:20:16 +08:00
46 lines
954 B
PHP
46 lines
954 B
PHP
<?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';
|
|
}
|
|
} |