1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-26 04:21:27 +08:00
2020-03-16 15:33:36 +08:00

38 lines
753 B
PHP

<?php
namespace App\Validators;
use App\Exceptions\Forbidden as ForbiddenException;
use App\Exceptions\Unauthorized as UnauthorizedException;
use Phalcon\Mvc\User\Component;
class Validator extends Component
{
public function checkAuthToken($token)
{
if (!$token) {
throw new UnauthorizedException('sys.invalid_auth_token');
}
return $token;
}
public function checkAuthUser($user)
{
if (!$user) {
throw new UnauthorizedException('sys.auth_user_failed');
}
return $user;
}
public function checkOwnerPriv($userId, $ownerId)
{
if ($userId != $ownerId) {
throw new ForbiddenException('sys.access_denied');
}
}
}