add login email sending

This commit is contained in:
2016-01-08 22:49:18 +01:00
parent 0084526094
commit b83d13ad2f
10 changed files with 292 additions and 104 deletions

View File

@@ -12,6 +12,8 @@ use yii\web\BadRequestHttpException;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\models\User;
use common\components\Helper;
/**
* Site controller
@@ -88,12 +90,31 @@ class SiteController extends Controller
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
// return $this->goBack();
return $this->redirect(['account/select']);
} else {
return $this->render('login', ['model' => $model,]);
}
}
protected function sendLoginIp(){
if ( \Yii::$app->params['login_reception_email'] == true){
$geoip = Helper::getGeoIp();
$user = User::findOne(\Yii::$app->user->id);
$message = \Yii::$app->mailer->compose('login_frontend', [
'model' => $user,
'geoip' => $geoip
]);
$message->setFrom( \Yii::$app->params['infoEmail'] )
->setTo( \Yii::$app->params['notify_mail'] )
->setSubject('Recepció bejelentkezés - ' . $user->username )
->send();
}
}
/**
* Logs out the current user.