Double Authentication

Hello all,

Please i have an issue that i want to solve in my projet.

My projet is about projet management.

An user can belong to many projects and a projet can have many users.

When a user go to the connection page and enters his username and password, i would like that

a second authentication page is displayed in which the user should choose his projet (a dropdownlist which displays the list of user’s project). after choosing his project, then the index.php page is display in which the user should see only the data concerning his project.

How can i do to solve it?

Please help me.

Best regards.

Any reply please?

After authentication the user see the page with the list of his projects to choose - this is not a second authentication, just the simple form with dropdown list. You can use the selected project ID as the parameter then to display the project data. Another idea is to set a session parameter with it for the same purpose.

Bizley give you a goog idea, you can use session with levels to define what each user can access in your project, for exemplo, if you have a table ‘users’ and there is a field called level and there are two levels saved in this field: ‘level1 and level2’, you can create a code in Controller components, example:




protected function getLevel1() 

        {

            $a = array();

            $users = Users::model()->level1()->findAll();

            if($users){ foreach($users as $k => $user) { $a[] = $user->user;} }

            else{ $a[0] = null;}

            return $a;

        }



This code find all users level one, in model Users create a scode, examplo:




...

const LEVEL1 = 'LEVEL1';

...

public function scopes()

        {

            return array(

                'level1' => array('condition' => 'level="'.self::LEVEL1 . '"')

               );

        }




So in yours controller put the role:




.....

 public function filters() {


        return array(

            'accessControl'

        );

    }

    

    public function accessRules(){

        return array(

            array('allow',

                    'actions'=>array('index','add','remover'),

                    'users'=>$this->getLevel1(),

            ),

            array('deny',  // deny all users

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

            ),

        );

    }




There is the RBAC too, is a good way:

http://www.yiiframework.com/wiki/328/simple-rbac

I have helped!