【问题标题】:Directing user to the desired page将用户引导至所需页面
【发布时间】:2015-11-08 15:17:51
【问题描述】:

我已经安装了 yii 用户和权限,通过“webapp/user/login”登录后,它会将我引导到 index.php 页面。 我想将管理员引导到另一个页面,而不是 index.php 页面。 我需要编辑哪个文件以将管理员引导到所需的页面。需要帮助。

【问题讨论】:

  • 显示站点控制器。您在哪里有操作登录
  • 我已经在代码中发布了一个答案,其中有注释解释重定向或呈现到您想要的页面。
  • 我正在使用 yii 用户和权限扩展。从 url “webapp/user/login” 登录后,我想进入 webapp/story/create 页面。我怎么能在你提到的代码中写这个。

标签: php authentication yii


【解决方案1】:

您的站点/控制器中应该有此代码

/**
 * Displays the login page
 */
public function actionLogin()
{
    $model=new LoginForm;

    // if it is ajax validation request
    if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
    {   
        echo CActiveForm::validate($model);
        Yii::app()->end();
    }

    // collect user input data
    if(isset($_POST['LoginForm']))
    {
        $model->attributes=$_POST['LoginForm'];
        // validate user input and redirect to the previous page if valid
        if($model->validate() && $model->login())
           // 
           //this if you want redirect to returnUrl (index.php by default) 
           // here you can change redirect to url you prefer 
           // or render proper page  
           // $this->redirect(Yii::app()->user->returnUrl);
           // this for your destination 
            $this->redirect(array('story/create'));
    }
    // display the login form
    $this->render('login',array('model'=>$model));
}

【讨论】:

  • 我正在使用 yii 用户和权限扩展。从 url “webapp/user/login” 登录后,我想进入 webapp/story/create 页面。我怎么能在你上面提到的代码中写这个。
  • 伙伴它不是将我从“webapp/user/login”重定向到“webapp/stroy/create”而不是从“webapp/site/login”重定向我到“webapp/故事/创作”
  • 请确保我使用的是yii用户和正确的扩展名..!!
  • 我不明白你的目标,请解释清楚。我想你登录后想去故事/创建...
  • 我想我在站点/登录名和用户/登录名之间感到困惑,我想两者都是一样的,对吗..??
猜你喜欢
  • 1970-01-01
  • 2011-04-14
  • 2011-12-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多