sxtuwy 2012-11-19 10:12:24 4133次浏览 7条回复 0 0 0

原文地址:http://www.yiichina.com/topic/353 我是原样拿过来的,我现在的问题是:在登录界面登录后仍然停留在登录界面,不能跳转到其它页面;虽然登录成功了,倡是访问其它后台页面,依然会跳转到登录界面。搞不懂是什么原因,我想可能是这个原因吧:

public function beforeControllerAction($controller, $action)
{
    if(parent::beforeControllerAction($controller, $action))
    {
        $route=$controller->id.'/'.$action->id;
        if(!$this->allowIp(Yii::app()->request->userHostAddress) && $route!=='default/error')
            throw new CHttpException(403,"You are not allowed to access this page.");

        $publicPages=array(
            'default/login',
            'default/error',
        );
        if(Yii::app()->user->isGuest && !in_array($route,$publicPages))
            Yii::app()->user->loginRequired();
        else
            return true;
    }
    return false;
}

这段代码搞不懂呀,各位给解释一下吧。

  • 回复于 2012-11-19 17:15 举报

    这样做同时登录时可以了 但是退出却不行 会同时退出

  • 回复于 2012-11-20 10:01 举报

    没试过~楼主发出个错误信息~

  • 回复于 2012-11-20 10:33 举报

    http://www.wukunfan.com/index.php/yii-admin-site-login.html 这是我的做法,表示成功了!

  • 回复于 2012-11-22 13:39 举报

    正在研究你的方法。你为什么要单独弄个WebUser这个类?

  • 回复于 2012-11-22 17:42 举报

    哦 你看一下这篇文章就知道了 http://www.yiichina.com/tutorial/5

  • 回复于 2012-12-01 20:59 举报

    我要访问后台提示在前台登录,从前台登录了,返回后台就错了
    CHttpException

    (D:\wamp\www\framework\web\auth\CAccessControlFilter.php:170)
    
    #0 D:\wamp\www\framework\web\auth\CAccessControlFilter.php(133): CAccessControlFilter->accessDenied(Object(WebUser), '???????????????...')
    #1 D:\wamp\www\framework\web\filters\CFilter.php(39): CAccessControlFilter->preFilter(Object(CFilterChain))
    #2 D:\wamp\www\framework\web\CController.php(1146): CFilter->filter(Object(CFilterChain))
    #3 D:\wamp\www\framework\web\filters\CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain))
    #4 D:\wamp\www\framework\web\filters\CFilterChain.php(131): CInlineFilter->filter(Object(CFilterChain))
    #5 D:\wamp\www\framework\web\CController.php(292): CFilterChain->run()
    #6 D:\wamp\www\framework\web\CController.php(266): CController->runActionWithFilters(Object(CInlineAction), Array)
    #7 D:\wamp\www\framework\web\CWebApplication.php(283): CController->run('error')
    #8 D:\wamp\www\framework\base\CErrorHandler.php(332): CWebApplication->runController('admin/default/e...')
    #9 D:\wamp\www\framework\base\CErrorHandler.php(205): CErrorHandler->render('error', Array)
    #10 D:\wamp\www\framework\base\CErrorHandler.php(130): CErrorHandler->handleException(Object(CHttpException))
    #11 D:\wamp\www\framework\base\CApplication.php(713): CErrorHandler->handle(Object(CExceptionEvent))
    #12 [internal function]: CApplication->handleException(Object(CHttpException))
    #13 {main}
    
  • 回复于 2012-12-09 09:12 举报

    [attach]1004[/attach]

您需要登录后才可以回复。登录 | 立即注册