refactor: restructure API authentication system and remove legacy files
- Updated API routes to use a unified versioning scheme under `/api/v1/auth`. - Implemented new authentication controller for login, registration, and token management. - Removed legacy user and index controllers, along with associated models and validation files. - Updated documentation to reflect new API endpoints and usage. - Cleaned up unused service and middleware files to streamline the application structure.
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 用户模型
|
||||
*/
|
||||
class User extends Model
|
||||
{
|
||||
// 表名
|
||||
protected $name = 'user';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
|
||||
// 类型转换
|
||||
protected $type = [
|
||||
'id' => 'integer',
|
||||
'status' => 'integer',
|
||||
];
|
||||
|
||||
// 隐藏字段
|
||||
protected $hidden = ['password', 'delete_time'];
|
||||
|
||||
/**
|
||||
* 密码加密
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
public function setPasswordAttr(string $value): string
|
||||
{
|
||||
return password_hash($value, PASSWORD_DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证密码
|
||||
* @param string $password 明文密码
|
||||
* @param string $hash 加密后的密码
|
||||
* @return bool
|
||||
*/
|
||||
public static function verifyPassword(string $password, string $hash): bool
|
||||
{
|
||||
return password_verify($password, $hash);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user