pages in login

Hi!

I’ve created several pages but I like to place it within the Login, that means the pages that I created should be first go to the login page. But how?

Hi. So just to clarify, you want pages to redirect to login in case the user hasn’t logged in?

yes! Whatever he direct to my page that i created if he is not login he would not access it unless he login…


array('allow', // allow authenticated user to perform 'logout' actions

				'actions'=>array('ur-action-names'),

				'users'=>array('@'),

			),



put in controller, "ur-action-names"

Check This

and use @ for authenticated users,


public function accessRules()

	{

		return array(			

			array('allow', 

				'actions'=>array('page1','page2','page3'), 	// authenticated pages

				'users'=>array('@'),

			),

..

..

..

This is my approach, it works well




class ArController extends Controller{

    public $layout = '//layouts/column2';


    /**

     * @return array action filters

     */

    public function filters() {

        return array(

            'accessControl', // perform access control for CRUD operations

            array(

                'application.filters.RequireLoginFilter + index,update,delete', 

            ),

        );

    }

?>



Here is my filter class:




<?php


// Created by Khanh Nam

class RequireLoginFilter extends CFilter {


    public function preFilter($filterChain) {


        if (Yii::app()->user->isGuest && Yii::app()->controller->route != 'site/login') {

            Yii::app()->controller->redirect(Yii::app()->controller->createUrl('site/login'));

        } 

        

        $filterChain->run();

    }

}

?>