render('index', [ ]); } /** * 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, ]); } }