4253cbec
root
first commit
|
1
2
3
4
|
<?php
namespace frontend\controllers;
|
a1a60fa5
Administrator
big commti
|
5
|
use common\components\Mailer;
|
4253cbec
root
first commit
|
6
|
use Yii;
|
a1a60fa5
Administrator
big commti
|
7
8
9
10
11
12
13
|
use common\models\LoginForm;
use frontend\models\PasswordResetRequestForm;
use frontend\models\ResetPasswordForm;
use frontend\models\SignupForm;
use frontend\models\ContactForm;
use yii\base\InvalidParamException;
use yii\web\BadRequestHttpException;
|
4253cbec
root
first commit
|
14
|
use yii\web\Controller;
|
a1a60fa5
Administrator
big commti
|
15
16
17
18
|
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use yii\web\Response;
use yii\widgets\ActiveForm;
|
4253cbec
root
first commit
|
19
20
|
class SiteController extends Controller
{
|
e337d04a
Administrator
liniya first commit
|
21
|
|
4253cbec
root
first commit
|
22
23
24
25
|
public function actionIndex()
{
|
4253cbec
root
first commit
|
26
27
|
return $this->render('index', [
|
4253cbec
root
first commit
|
28
29
|
|
4253cbec
root
first commit
|
30
31
32
|
]);
}
|
4253cbec
root
first commit
|
33
|
|
a1a60fa5
Administrator
big commti
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/**
* Logs in a user.
*
* @return mixed
*/
public function actionLogin()
{
if (!\Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
return $this->render('index', [
'model' => $model,
]);
}
}
/**
* Signs user up.
*
* @return mixed
*/
public function actionSignup()
{
if(Yii::$app->request->post()){
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = Response::FORMAT_JSON;
$model = new SignupForm();
$model->load(Yii::$app->request->post());
return ActiveForm::validate($model);
} else {
$model = new SignupForm();
$model->load(Yii::$app->request->post());
if ($user = $model->signup()) {
if (Yii::$app->getUser()->login($user)) {
return $this->goHome();
}
}
}
}
return $this->render('signup', [
'model' => $model,
]);
}
|
4253cbec
root
first commit
|
86
87
|
}
|