1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-24 20:06:09 +08:00
2020-01-30 16:51:10 +08:00

37 lines
739 B
PHP

<?php
namespace App\Validators;
use App\Exceptions\Forbidden as ForbiddenException;
use App\Exceptions\Unauthorized as UnauthorizedException;
class Validator extends \Phalcon\Mvc\User\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');
}
}
}