1. Go to this page and download the library: Download yii1tech/web-user library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace app\web\controllers;
use app\models\OAuthToken;
use app\models\User;
use CController;
use Yii;
use yii1tech\session\dummy\DummySession;
class ApiController extends CController
{
public function init()
{
parent::init();
// mock session, so it does not send any Cookies to the API client:
Yii::app()->setComponent('session', new DummySession(), false);
// find OAuth token matching request:
$oauthToken = OAuthToken::model()->findByPk(Yii::app()->request->getParam('oauth_token'));
if (!$oauthToken) {
return;
}
// find User matching OAuth token:
$user = User::model()->findByPk($oauthToken->user_id);
if (!$user) {
return;
}
// act as found user:
Yii::app()->user->setModel($user);
}
public function filters()
{
return [
'accessControl', // now we can freely use standard "access control" filter and other features
];
}
public function accessRules()
{
return [
// ...
];
}
// ...
}
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.