<?php
/**
 * 获取access_token以及验证access_token 在此类中完成 每个Base类模块相对独立
 * User: Airon
 * Date: 2018/7/17
 * Time: 上午11:04
 */

namespace app\api\controller\v1\app;

use app\api\model\UserToken;
use app\api\controller\Api;

class Base extends Api
{
    /**
     * @author: Airon
     * @time:   2018年5月
     * description
     * @return array|bool|false|\PDOStatement|string|\think\Model
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    protected function validateToken()
    {
        $token = get_token();
        $bool = UserToken::build()->validateToken($token);
        if (!$bool) {
            self::returnmsg(401, [], [], "", "AUTH ERROR", "鉴权失败");
        }

        return $bool;
    }
}