<?php
/**
 * Created by IntelliJ IDEA.
 * User: solu
 * Date: 2019/3/8
 * Time: 3:08 PM
 */
class UserController extends BaseController {

    /**
     * 获取授权地址
     * @author solu
     * @param $args
     * @return string
     */
    public function actionGetAuthUrl($args) {
        $rules = [];
        Param::checkParam2($rules, $args);

        return ThirdApi::getAuthUrl(SITE_URL . 'user/authCallback');
    }

    /**
     * 用户授权回调
     * @author solu
     * @param $args
     * @return array
     */
    public function actionAuthCallback($args) {
        $rules = [
            'user_id' => ['int', 'desc' => '用户id'],
            'access_token' => ['string', 'desc' => 'access_token'],
        ];
        Param::checkParam2($rules, $args);

        return User::getInfo();
    }
}