1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace app\common\filters;
- use Yii;
- use yii\base\ActionFilter;
- class FrontEndAuthFilter extends ActionFilter
- {
- public function beforeAction($action)
- {
- //未登录或COOKIE认证失败
- $identityInfo = Yii::$app->controller->getIdentityInfo();
- if(defined('IN_WAP')&&IN_WAP==TRUE)
- {
- $loginUrl = \app\common\components\SiteUrl::loginhome();
- }
- else
- {
- $loginUrl = \app\common\components\SiteUrl::login();
- }
- if(!empty($identityInfo)&&is_array($identityInfo))
- {
- if(sys_auth($identityInfo['cookieHash'],'DECODE')!=$identityInfo['user_name'])
- {
- Yii::$app->controller->showMessage(array('class'=>'warning','message'=>'您还没有登录,请先登录!','url'=>$loginUrl,'time'=>0));
- return false;
- }
- }
- else
- {
- Yii::$app->controller->showMessage(array('class'=>'warning','message'=>'您还没有登录,请先登录!','url'=>$loginUrl,'time'=>0));
- return false;
- }
- return true;
- }
- }
|