1
0

Added LogIn (pw in db)

This commit is contained in:
2014-05-28 10:38:11 +02:00
parent d74a13f661
commit fa36f26f2e
9 changed files with 2851 additions and 143 deletions

View File

@@ -57,8 +57,41 @@ class SiteController extends Controller
$data['model'] = new SendMailForm();
}
$this->render('about', $data);
}
/**
* 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 TbActiveForm::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->redirect(Yii::app()->user->returnUrl);
}
// display the login form
$this->render('login', array('model'=>$model));
}
/**
* Logs out the current user and redirect to homepage.
*/
public function actionLogout()
{
Yii::app()->user->logout();
$this->redirect(Yii::app()->homeUrl);
}
}