更新初始化

This commit is contained in:
技术老胡
2026-01-07 12:05:47 +08:00
parent 68dfc68cb6
commit f8224969c5
15 changed files with 124 additions and 2198 deletions

View File

@@ -1,6 +1,6 @@
<?php
namespace app\http\admin\controller;
namespace app\controller;
use support\Request;
@@ -23,8 +23,8 @@ class IndexController
src="https://www.workerman.net/wellcome"
width="100%"
height="100%"
allow="*"
sandbox="allow-scripts allow-same-origin"
allow="clipboard-write"
sandbox="allow-scripts allow-same-origin allow-popups"
></iframe>
EOF;
}

View File

@@ -1,26 +0,0 @@
<?php
namespace app\http\admin\middleware;
use Webman\MiddlewareInterface;
use Webman\Http\Response;
use Webman\Http\Request;
/**
* Class UserAuthMiddleware
* @package app\http\admin\middleware
*/
class UserAuthMiddleware implements MiddlewareInterface
{
public function process(Request $request, callable $handler): Response
{
// 检查用户是否已经登录,这里假设通过 session 中的 'user_id' 判断
if (!$request->session()->has('user_id')) {
// 用户未登录,重定向到登录页面
return redirect('/login');
}
// 用户已登录,继续处理请求
return $handler($request);
}
}

View File

@@ -1,8 +0,0 @@
<?php
use Webman\Route;

View File

@@ -1,39 +0,0 @@
<?php
namespace app\http\admin\validate;
use Respect\Validation\Validator as v;
class UserValidator
{
/**
* 验证用户数据
*
* @param array $data 包含用户信息的数组,应包含 'username', 'email', 'password' 键
* @return array 包含验证错误信息的数组,若验证通过则返回空数组
*/
public function validate(array $data)
{
$errors = [];
// 验证用户名
$usernameValidator = v::stringType()->length(3, 20)->alnum();
if (!$usernameValidator->validate($data['username'] ?? '')) {
$errors['username'] = '用户名必须为 3 到 20 个字母或数字字符';
}
// 验证邮箱
$emailValidator = v::email();
if (!$emailValidator->validate($data['email'] ?? '')) {
$errors['email'] = '请输入有效的邮箱地址';
}
// 验证密码
$passwordValidator = v::stringType()->length(6, null);
if (!$passwordValidator->validate($data['password'] ?? '')) {
$errors['password'] = '密码至少需要 6 个字符';
}
return $errors;
}
}