blessing-skin-server/app/Middlewares/CheckPostMiddleware.php

39 lines
1.0 KiB
PHP
Raw Normal View History

2016-07-21 22:01:57 +08:00
<?php
namespace App\Middlewares;
use \Pecee\Http\Middleware\IMiddleware;
use \Pecee\Http\Request;
use App\Exceptions\E;
2016-07-28 15:09:29 +08:00
use Validate;
use Utils;
use View;
2016-07-21 22:01:57 +08:00
class CheckPostMiddleware implements IMiddleware
{
public function handle(Request $request)
{
2016-08-16 13:27:06 +08:00
if (Utils::getValue('email', $_POST) != "") {
2016-08-06 19:38:37 +08:00
if (!Validate::email($_POST['email'])) {
View::json('邮箱或角色名格式错误', 3);
2016-07-21 22:01:57 +08:00
}
2016-08-16 13:27:06 +08:00
$_SESSION['auth_type'] = 'email';
} elseif (Utils::getValue('username', $_POST) != "") {
if (!Validate::playerName($_POST['username'])) {
View::json('邮箱或角色名格式错误', 3);
2016-08-16 13:27:06 +08:00
}
$_SESSION['auth_type'] = 'username';
} else {
View::json('无效的参数', 3);
}
2016-07-21 22:01:57 +08:00
2016-08-16 13:27:06 +08:00
if ($request->getUri() == "/auth/forgot") return true;
2016-07-21 22:01:57 +08:00
2016-08-16 13:27:06 +08:00
if (isset($_POST['password']) && $_POST['password'] != "") {
return true;
2016-07-21 22:01:57 +08:00
} else {
2016-08-16 13:27:06 +08:00
View::json('密码不能为空哦', 2);
2016-07-21 22:01:57 +08:00
}
}
}