Yii Framework Forum: Module based login - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Module based login Can't figure out what I am doing wrong Rate Topic: -----

#1 User is offline   Julie 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 36
  • Joined: 01-August 11

Posted 22 October 2011 - 10:13 AM

Hello,

(Sorry for my bad English, but I am from France and trying my best)

I have a webApplication with an admin module.
We can login in the admin module or on the website, but the two logins are completely independant. I think that it was working before, but now, when I go to index.php?r=admin, I am redirected to index.php?r=site/login instead of index.php?r=admin/index/login. And when I loggin on the website, I can access the admin interface like if I was logged in.

Here is my config/main.php
<?php
return array(
	// autoloading model and component classes
	'import'=>array(
		'application.extensions.*',
		'application.models.*',
		'application.components.*',
		'application.behaviors.*',
		'application.helpers.*',
		'application.widget.*',
	),
	'modules'=>array(
		'admin',
	),

	// application components
	'components'=>array(
		'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
			'loginUrl'=>array('site/login'),
		),
		'errorHandler'=>array(
			// use 'site/error' action to display errors
         		'errorAction'=>'site/error',
		 ),
	),
);


And here is the AdminModule.php
<?php

class AdminModule extends CWebModule
{
	public $defaultController = 'index';
	
	public function init()
	{
		// this method is called when the module is being created
		// you may place code here to customize the module or the application

		// import the module-level models and components
		$this->setImport(array(
			'admin.models.*',
			'admin.components.*',
		));
		
		Yii::app()->setComponents(array(
			'user' => array(
				'class'          => 'CWebUser',
				'stateKeyPrefix' => 'admin',
				'loginUrl'       => Yii::app()->createUrl('/admin/index/login'),
			),
			'errorHandler'=>array(
				'errorAction'=>'/admin/index/error',
			)
		));		
	}

	public function beforeControllerAction($controller, $action)
	{
		if(parent::beforeControllerAction($controller, $action))
		{
			// this method is called before any module controller action is performed
			// you may place customized code here
			return true;
		}
		else
			return false;
	}
}


I only use basic login form and user identities.
So if you have any idea of what I could be missing, it would be a great help
Thanks !!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users