Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yiier/yii2-return-url
Yii2 Login ReturnUrl filter 中文说明:登录之后自动跳转登录之前的页面
https://github.com/yiier/yii2-return-url
yii yii2-behaviors yii2-extension
Last synced: 2 months ago
JSON representation
Yii2 Login ReturnUrl filter 中文说明:登录之后自动跳转登录之前的页面
- Host: GitHub
- URL: https://github.com/yiier/yii2-return-url
- Owner: yiier
- License: bsd-3-clause
- Created: 2016-03-16T03:18:59.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-02-17T14:29:05.000Z (almost 5 years ago)
- Last Synced: 2024-04-14T05:41:48.781Z (8 months ago)
- Topics: yii, yii2-behaviors, yii2-extension
- Language: PHP
- Homepage: http://www.getyii.com/
- Size: 5.86 KB
- Stars: 10
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-yii2 - yiier/yiier-return-url
README
Yii2 Login ReturnUrl filter
===========================
[![Latest Stable Version](https://poser.pugx.org/yiier/yii2-return-url/v/stable)](https://packagist.org/packages/yiier/yii2-return-url)
[![Total Downloads](https://poser.pugx.org/yiier/yii2-return-url/downloads)](https://packagist.org/packages/yiier/yii2-return-url)
[![Latest Unstable Version](https://poser.pugx.org/yiier/yii2-return-url/v/unstable)](https://packagist.org/packages/yiier/yii2-return-url)
[![License](https://poser.pugx.org/yiier/yii2-return-url/license)](https://packagist.org/packages/yiier/yii2-return-url)Keeps current URL in session for login actions so we can return to it if needed.
中文说明:登录之后自动跳转登录之前的页面
Installation
------------The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require --prefer-dist yiier/yii2-return-url "*"
```or add
```
"yiier/yii2-return-url": "*"
```to the require section of your `composer.json` file.
Usage
-----## Method One (方式一,推荐)
you need to include it in config:
```php
return [
'on beforeAction' => function ($event) {
Yii::createObject([
'class' => \yiier\returnUrl\ReturnUrl::class,
'uniqueIds' => ['site/qrcode', 'site/login', 'site/signup']
])->beforeAction();
},
'components' => [
]
];
```## Method Two (方式二)
In your controller add ReturnUrl filter to behaviors:```php
public function behaviors()
{
return [
'returnUrl' => [
'class' => 'yiier\returnUrl\ReturnUrl',
'uniqueIds' => ['site/qrcode', 'site/login', 'user/security/auth'] // 过滤掉不需要的 controller/action
],
];
}
```For access to previously visited url:
```php
Yii::$app->user->getReturnUrl();
```