Module Login in Basic Template

Using the "basic" application template, what is the correct way of setting up a module login that is separate from the main site login?

For example I have an "admin" module which requires a login. I also need a user login for the main site.

I have done the following:

  1. Created "admin" module using gii tool

  2. Created "models" folder within the "admin" module folder

  3. Placed "LoginForm.php" and "User.php" within this folder (also updated the namespace declarations in these files)

  4. Added AccessControl behaviour and login/logout actions to "modules\admin\controllers\DefaultController.php"

  5. Updated "config\web.php" as follows:

'user' => [

	'identityClass' => 'app\modules\admin\models\User',

	'enableAutoLogin' => true,


The problem I am having is when I log in to the admin module it redirects me back to the main site. It should redirect me to the previous page (or the module home page).

In DefaultController.php, it has the following:

if ($model->load(Yii::$app->request->post()) && $model->login())

	return $this->goBack();

What is the correct way of doing this so I can have independent logins for the admin module and for the main site? Do I have to use the "advanced" application template or can I still do this using the "basic" template?

Anyone got any idea?