add login email sending
This commit is contained in:
parent
0084526094
commit
b83d13ad2f
@ -7,6 +7,8 @@ use yii\web\Controller;
|
|||||||
use common\models\LoginForm;
|
use common\models\LoginForm;
|
||||||
use yii\filters\VerbFilter;
|
use yii\filters\VerbFilter;
|
||||||
use backend\models\UploadForm;
|
use backend\models\UploadForm;
|
||||||
|
use common\components\Helper;
|
||||||
|
use common\models\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Site controller
|
* Site controller
|
||||||
@ -71,6 +73,9 @@ class SiteController extends Controller
|
|||||||
'employee'
|
'employee'
|
||||||
];
|
];
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->login()) {
|
if ($model->load(Yii::$app->request->post()) && $model->login()) {
|
||||||
|
|
||||||
|
$this->sendLoginMail();
|
||||||
|
|
||||||
return $this->goBack();
|
return $this->goBack();
|
||||||
} else {
|
} else {
|
||||||
return $this->render('login', [
|
return $this->render('login', [
|
||||||
@ -79,6 +84,23 @@ class SiteController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function sendLoginMail(){
|
||||||
|
if ( \Yii::$app->params['login_admin_email'] == true){
|
||||||
|
$geoip = Helper::getGeoIp();
|
||||||
|
|
||||||
|
$user = User::findOne(\Yii::$app->user->id);
|
||||||
|
$message = \Yii::$app->mailer->compose('login_admin', [
|
||||||
|
'model' => $user,
|
||||||
|
'geoip' => $geoip
|
||||||
|
]);
|
||||||
|
|
||||||
|
$message->setFrom( \Yii::$app->params['infoEmail'] )
|
||||||
|
->setTo( \Yii::$app->params['notify_mail'] )
|
||||||
|
->setSubject('Admin bejelentkezés - ' . $user->username )
|
||||||
|
->send();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function actionLogout()
|
public function actionLogout()
|
||||||
{
|
{
|
||||||
Yii::$app->user->logout();
|
Yii::$app->user->logout();
|
||||||
|
|||||||
@ -1,101 +1,184 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace common\components;
|
namespace common\components;
|
||||||
|
|
||||||
use \Yii;
|
use \Yii;
|
||||||
|
|
||||||
class Helper
|
class Helper {
|
||||||
{
|
public static function hufRound($m) {
|
||||||
|
$result = round ( $m / 5, 0 ) * 5;
|
||||||
public static function hufRound($m){
|
|
||||||
$result = round($m/5, 0) * 5;
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
public static function notInInterval($query, $field, $start, $end) {
|
||||||
|
$query->andFilterWhere ( [
|
||||||
|
'or',
|
||||||
public static function notInInterval($query ,$field , $start,$end ){
|
[
|
||||||
$query->andFilterWhere( ['or', [ '<', $field , isset( $start ) ? $start : '1900-01-01' ] ,[ '>=' , $field , isset($end) ? $end : '3000-01-01' ] ] );
|
'<',
|
||||||
|
$field,
|
||||||
|
isset ( $start ) ? $start : '1900-01-01'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'>=',
|
||||||
|
$field,
|
||||||
|
isset ( $end ) ? $end : '3000-01-01'
|
||||||
|
]
|
||||||
|
] );
|
||||||
}
|
}
|
||||||
|
public static function notPaid($query, $field, $start, $end) {
|
||||||
public static function notPaid($query ,$field , $start,$end ){
|
$query->andFilterWhere ( [
|
||||||
$query->andFilterWhere( ['or', [ '<', $field , isset( $start ) ? $start : '1900-01-01' ] ,[ '>=' , $field , isset($end) ? $end : '3000-01-01' ] ,[ "transfer.status" => Transfer::STATUS_NOT_PAID ] ] );
|
'or',
|
||||||
|
[
|
||||||
|
'<',
|
||||||
|
$field,
|
||||||
|
isset ( $start ) ? $start : '1900-01-01'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'>=',
|
||||||
|
$field,
|
||||||
|
isset ( $end ) ? $end : '3000-01-01'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"transfer.status" => Transfer::STATUS_NOT_PAID
|
||||||
|
]
|
||||||
|
] );
|
||||||
}
|
}
|
||||||
public static function inInterval($query ,$field , $start,$end ){
|
public static function inInterval($query, $field, $start, $end) {
|
||||||
$query->andFilterWhere([ '>=', $field , $start ] );
|
$query->andFilterWhere ( [
|
||||||
$query->andFilterWhere([ '<' , $field , $end ] );
|
'>=',
|
||||||
|
$field,
|
||||||
|
$start
|
||||||
|
] );
|
||||||
|
$query->andFilterWhere ( [
|
||||||
|
'<',
|
||||||
|
$field,
|
||||||
|
$end
|
||||||
|
] );
|
||||||
}
|
}
|
||||||
|
public static function queryInIntervalRule($field, $start, $end) {
|
||||||
public static function queryInIntervalRule( $field , $start,$end ){
|
return [
|
||||||
return ['and',[ '>=', $field , $start ] , [ '<' , $field , $end ] ];
|
'and',
|
||||||
|
[
|
||||||
|
'>=',
|
||||||
|
$field,
|
||||||
|
$start
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'<',
|
||||||
|
$field,
|
||||||
|
$end
|
||||||
|
]
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
public static function queryExpireRule($field_start, $field_end, $start, $end) {
|
||||||
public static function queryExpireRule( $field_start,$field_end , $start,$end ){
|
return [
|
||||||
|
'and',
|
||||||
return ['and' ,['<',$field_start, $end], ['>=' , $field_end , $start ], ['<=' , $field_end , $end ] ];
|
[
|
||||||
|
'<',
|
||||||
|
$field_start,
|
||||||
|
$end
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'>=',
|
||||||
|
$field_end,
|
||||||
|
$start
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'<=',
|
||||||
|
$field_end,
|
||||||
|
$end
|
||||||
|
]
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
public static function queryValidRule($field_start, $field_end, $start, $end) {
|
||||||
public static function queryValidRule( $field_start ,$field_end , $start,$end ){
|
return [
|
||||||
return ['and' ,['<',$field_start, $end], ['>=' , $field_end , $start ] ];
|
'and',
|
||||||
|
[
|
||||||
|
'<',
|
||||||
|
$field_start,
|
||||||
|
$end
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'>=',
|
||||||
|
$field_end,
|
||||||
|
$start
|
||||||
|
]
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
public static function sqlInIntervalRule($field, $paramStart, $paramEnd) {
|
||||||
public static function sqlInIntervalRule( $field , $paramStart,$paramEnd ){
|
return ' ' . $field . ' >= ' . $paramStart . ' and ' . $field . ' < ' . $paramEnd;
|
||||||
return ' ' .$field . ' >= ' . $paramStart . ' and ' . $field . ' < ' . $paramEnd ;
|
|
||||||
}
|
}
|
||||||
|
public static function sqlExpireRule($field_start, $field_end, $paramStart, $paramEnd) {
|
||||||
public static function sqlExpireRule( $field_start,$field_end , $paramStart,$paramEnd ){
|
return ' ' . $field_start . ' < ' . $paramEnd . ' and ' . $field_end . ' < ' . $paramEnd;
|
||||||
return ' ' .$field_start . ' < ' . $paramEnd . ' and ' . $field_end . ' < ' . $paramEnd ;
|
|
||||||
}
|
}
|
||||||
|
public static function sqlValidRule($field_start, $field_end, $paramStart, $paramEnd) {
|
||||||
public static function sqlValidRule( $field_start ,$field_end , $paramStart,$paramEnd ){
|
return ' ' . $field_start . ' < ' . $paramEnd . ' and ' . $field_end . ' >=' . $paramStart;
|
||||||
return ' ' .$field_start . ' < ' . $paramEnd . ' and ' . $field_end . ' >=' . $paramStart ;
|
|
||||||
}
|
}
|
||||||
|
public static function queryAccountConstraint($query, $field) {
|
||||||
public static function queryAccountConstraint($query,$field){
|
if (! RoleDefinition::isAdmin ()) {
|
||||||
if ( !RoleDefinition::isAdmin() ){
|
$query->innerJoin ( "user_account_assignment", $field . ' = user_account_assignment.id_account' );
|
||||||
$query->innerJoin("user_account_assignment", $field . ' = user_account_assignment.id_account' );
|
$query->andWhere ( [
|
||||||
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]);
|
'user_account_assignment.id_user' => Yii::$app->user->id
|
||||||
|
] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static function roleLabels() {
|
||||||
|
return [
|
||||||
public static function roleLabels(){
|
'reception' => Yii::t ( 'common/role', 'Reception' ),
|
||||||
return [
|
'admin' => Yii::t ( 'common/role', 'Administrator' ),
|
||||||
'reception' => Yii::t('common/role' ,'Reception'),
|
'employee' => Yii::t ( 'common/role', 'Alkalmazott' )
|
||||||
'admin' => Yii::t('common/role' ,'Administrator'),
|
|
||||||
'employee' => Yii::t('common/role' ,'Alkalmazott'),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
public static function roleDefinitions() {
|
||||||
public static function roleDefinitions(){
|
return [
|
||||||
return [
|
'employee' => [
|
||||||
'employee' => [
|
'canAllow' => [
|
||||||
'canAllow' => [ 'employee'],
|
'employee'
|
||||||
|
]
|
||||||
],
|
],
|
||||||
'admin' => [
|
'admin' => [
|
||||||
'canAllow' => ['admin','reception','employee'],
|
'canAllow' => [
|
||||||
],
|
'admin',
|
||||||
'reception' => [
|
'reception',
|
||||||
'canAllow' => [ ],
|
'employee'
|
||||||
|
]
|
||||||
],
|
],
|
||||||
|
'reception' => [
|
||||||
|
'canAllow' => [ ]
|
||||||
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
public static function flash($mode, $message) {
|
||||||
public static function flash($mode,$message){
|
\Yii::$app->session->setFlash ( $mode, $message );
|
||||||
\Yii::$app->session->setFlash($mode, $message );
|
|
||||||
}
|
}
|
||||||
|
public static function fixAsciiChars($in) {
|
||||||
|
$out = str_replace ( "ö", "0", $in );
|
||||||
public static function fixAsciiChars($in){
|
$out = str_replace ( "Ö", "0", $out );
|
||||||
$out = str_replace("ö", "0", $in);
|
|
||||||
$out = str_replace("Ö", "0", $out);
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
public static function isCompanyMovar() {
|
||||||
public static function isCompanyMovar(){
|
return \Yii::$app->params ['company'] == 'movar';
|
||||||
return \Yii::$app->params['company'] == 'movar';
|
|
||||||
}
|
}
|
||||||
public static function isProductVisibilityAccount(){
|
public static function isProductVisibilityAccount() {
|
||||||
return \Yii::$app->params['product_visiblity'] == 'account';
|
return \Yii::$app->params ['product_visiblity'] == 'account';
|
||||||
|
}
|
||||||
|
public static function getRealUserIp() {
|
||||||
|
$client = @$_SERVER ['HTTP_CLIENT_IP'];
|
||||||
|
$forward = @$_SERVER ['HTTP_X_FORWARDED_FOR'];
|
||||||
|
$remote = $_SERVER ['REMOTE_ADDR'];
|
||||||
|
|
||||||
|
if (filter_var ( $client, FILTER_VALIDATE_IP )) {
|
||||||
|
$ip = $client;
|
||||||
|
} elseif (filter_var ( $forward, FILTER_VALIDATE_IP )) {
|
||||||
|
$ip = $forward;
|
||||||
|
} else {
|
||||||
|
$ip = $remote;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ip;
|
||||||
|
}
|
||||||
|
public static function getGeoIp() {
|
||||||
|
$ip = Helper::getRealUserIp ();
|
||||||
|
$details = json_decode ( file_get_contents ( "http://ipinfo.io/{$ip}/json" ) );
|
||||||
|
return $details;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -14,47 +14,54 @@ use common\components\DailyListing;
|
|||||||
class AccountStateMail extends Object {
|
class AccountStateMail extends Object {
|
||||||
|
|
||||||
|
|
||||||
|
public $controller;
|
||||||
public $model;
|
public $model;
|
||||||
|
public $user;
|
||||||
|
public $account;
|
||||||
|
public $message;
|
||||||
|
public $details;
|
||||||
|
|
||||||
public function init(){
|
public function init(){
|
||||||
|
|
||||||
|
$this->user = User::findOne($this->model->id_user);
|
||||||
|
$this->account = Account::findOne($this->model->id_account);
|
||||||
|
|
||||||
}
|
$this->details = null;
|
||||||
|
|
||||||
|
|
||||||
public function sednMail(){
|
|
||||||
|
|
||||||
$details = null;
|
|
||||||
if ($this->model ->isTypeClose ()) {
|
if ($this->model ->isTypeClose ()) {
|
||||||
|
|
||||||
$prev;
|
$prev;
|
||||||
if ($this->model ->type == AccountState::TYPE_CLOSE) {
|
if ($this->model->type == AccountState::TYPE_CLOSE) {
|
||||||
if (isset ( $accountState->prev_state )) {
|
if (isset ( $this->model->prev_state )) {
|
||||||
$prev = AccountState::findOne ( $accountState->prev_state );
|
$prev = AccountState::findOne ( $this->model->prev_state );
|
||||||
}
|
}
|
||||||
if (isset ( $prev )) {
|
if (isset ( $prev )) {
|
||||||
$this->model ->start_date = $prev->created_at;
|
$this->model ->start_date = $prev->created_at;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$details = new DailyListing();
|
$this->details = new DailyListing();
|
||||||
$details->loadAccountState ( $this->model );
|
$this->details->loadAccountState ( $this->model );
|
||||||
|
|
||||||
$details->readTotalEasy ();
|
$this->details->readTotalEasy ();
|
||||||
$details->readTotalDetailed ();
|
$this->details->readTotalDetailed ();
|
||||||
$details->readTotalMedium ();
|
$this->details->readTotalMedium ();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function sednMail(){
|
||||||
|
|
||||||
$user = User::findOne($this->model->id_user);
|
|
||||||
$account = Account::findOne($this->model->id_account);
|
|
||||||
$subject = $this->model->isTypeOpen() ? "Kassza nyitás " : "Kassza zárás";
|
$subject = $this->model->isTypeOpen() ? "Kassza nyitás " : "Kassza zárás";
|
||||||
$subject .= " - " . $user->username ." - ". $account->name;
|
$subject .= " - " . $this->user->username ." - ". $this->account->name;
|
||||||
|
|
||||||
$mail = \Yii::$app->mailer->compose('account_state', [
|
$this->message = \Yii::$app->mailer->compose('account_state', [
|
||||||
'model' => $this->model,
|
'model' => $this->model,
|
||||||
'details' => $details
|
'details' => $this->details
|
||||||
]);
|
]);
|
||||||
$mail->setFrom('noreplay@fitnessadmin.hu')
|
|
||||||
|
$this->attachPdf();
|
||||||
|
|
||||||
|
$this->message->setFrom('noreplay@fitnessadmin.hu')
|
||||||
->setTo( \Yii::$app->params['notify_mail'] )
|
->setTo( \Yii::$app->params['notify_mail'] )
|
||||||
->setSubject($subject )
|
->setSubject($subject )
|
||||||
->send();
|
->send();
|
||||||
@ -62,6 +69,30 @@ class AccountStateMail extends Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function attachPdf(){
|
||||||
|
$mpdf=new \mPDF('utf-8', 'A4-L');
|
||||||
|
$mpdf->useSubstitutions=false;
|
||||||
|
$mpdf->simpleTables = true;
|
||||||
|
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
|
||||||
|
$mpdf->setFooter('{PAGENO} / {nb}');
|
||||||
|
|
||||||
|
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
|
||||||
|
$mpdf->WriteHTML($stylesheet,1);
|
||||||
|
|
||||||
|
|
||||||
|
$mpdf->WriteHTML($this->controller->renderPartial("@common/views/account-state/account_state_pdf", [
|
||||||
|
'model' => $this->model,
|
||||||
|
'details' => $this->details
|
||||||
|
]));
|
||||||
|
$type = $this->model->isTypeOpen() ? "kassza_nyitas" : "kassza_zaras";
|
||||||
|
$dt= "_letrehozva_".date("Ymd_His"). "_" . $this->user->username;
|
||||||
|
$fn= $type .$dt.".pdf";
|
||||||
|
$content = $mpdf->Output($fn, 'S');
|
||||||
|
|
||||||
|
$this->message->attachContent($content, ['fileName' => $fn, 'contentType' => 'application/pdf']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2,6 +2,7 @@
|
|||||||
return [
|
return [
|
||||||
'adminEmail' => 'rocho02@gmail.com',
|
'adminEmail' => 'rocho02@gmail.com',
|
||||||
'supportEmail' => 'rocho02@gmail.com',
|
'supportEmail' => 'rocho02@gmail.com',
|
||||||
|
'infoEmail' => 'info@rocho-net.hu',
|
||||||
'user.passwordResetTokenExpire' => 3600,
|
'user.passwordResetTokenExpire' => 3600,
|
||||||
'version' => 'v0.0.19',
|
'version' => 'v0.0.19',
|
||||||
'company' => 'movar',//gyor
|
'company' => 'movar',//gyor
|
||||||
@ -9,4 +10,7 @@ return [
|
|||||||
'product_visiblity' => 'account',// on reception which products to display. account or global
|
'product_visiblity' => 'account',// on reception which products to display. account or global
|
||||||
'notify_mail' => ['rocho02@gmail.com' ],
|
'notify_mail' => ['rocho02@gmail.com' ],
|
||||||
'mail_account_state_open' => true,
|
'mail_account_state_open' => true,
|
||||||
|
'login_reception_email' => true, //if reception login should send email
|
||||||
|
'login_admin_email' => true, //if admin login should send email
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@ -79,9 +79,6 @@ if ( $model ->type == AccountState::TYPE_OPEN ){
|
|||||||
<?php echo TotalMediumProductsWidget::widget(['dailyListing' => $details]);?>
|
<?php echo TotalMediumProductsWidget::widget(['dailyListing' => $details]);?>
|
||||||
<h3>Pénzmozgások típus szerint</h3>
|
<h3>Pénzmozgások típus szerint</h3>
|
||||||
<?php echo TotalMediumMoneyMovementsWidget::widget(['dailyListing' => $details]);?>
|
<?php echo TotalMediumMoneyMovementsWidget::widget(['dailyListing' => $details]);?>
|
||||||
<?php }else{?>
|
<?php } ?>
|
||||||
<h2>Címletek</h2>
|
|
||||||
<?php echo BankNotesWidget::widget(['model' => $model]);?>
|
|
||||||
<?php }?>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
12
common/mail/login_admin.php
Normal file
12
common/mail/login_admin.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
?>
|
||||||
|
<h1>Admin bejelentkezés:</h1>
|
||||||
|
<b>Felhasználó:</b> <?php echo $model->username ;?><br>
|
||||||
|
<b>Idő:</b> <?php echo \Yii::$app->formatter->asDatetime(time());?><br>
|
||||||
|
<?php
|
||||||
|
if ( isset($geoip->city)){
|
||||||
|
?>
|
||||||
|
<b>Ip cím:</b> <?php echo $geoip->ip?><br>
|
||||||
|
<b>Város:</b> <?php echo $geoip->city?><br>
|
||||||
|
<?php }?>
|
||||||
12
common/mail/login_frontend.php
Normal file
12
common/mail/login_frontend.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
?>
|
||||||
|
<h1>Recepció bejelentkezés:</h1>
|
||||||
|
<b>Felhasználó:</b> <?php echo $model->username ;?><br>
|
||||||
|
<b>Idő:</b> <?php echo \Yii::$app->formatter->asDatetime(time());?><br>
|
||||||
|
<?php
|
||||||
|
if ( isset($geoip->city)){
|
||||||
|
?>
|
||||||
|
<b>Ip cím:</b> <?php echo $geoip->ip?><br>
|
||||||
|
<b>Város:</b> <?php echo $geoip->city?><br>
|
||||||
|
<?php }?>
|
||||||
@ -11,8 +11,14 @@ return [
|
|||||||
'mailer' => [
|
'mailer' => [
|
||||||
'class' => 'yii\swiftmailer\Mailer',
|
'class' => 'yii\swiftmailer\Mailer',
|
||||||
'viewPath' => '@common/mail',
|
'viewPath' => '@common/mail',
|
||||||
'fileTransport' => true,
|
'useFileTransport' =>false,
|
||||||
'transport' =>[]
|
'transport' => [
|
||||||
],
|
'class' => 'Swift_SmtpTransport',
|
||||||
],
|
'host' => 'smtp.websiter.hu',
|
||||||
|
'username' => 'info@rocho-net.hu',
|
||||||
|
'password' => 'botond2015',
|
||||||
|
'port' => '25',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]
|
||||||
];
|
];
|
||||||
|
|||||||
@ -80,7 +80,7 @@ class AccountStateController extends Controller {
|
|||||||
// return $this->redirect(['view', 'id' => $model->id_account_state]);
|
// return $this->redirect(['view', 'id' => $model->id_account_state]);
|
||||||
|
|
||||||
|
|
||||||
$mail = new AccountStateMail(['model' => $model]);
|
$mail = new AccountStateMail(['model' => $model,'controller' => $this]);
|
||||||
$mail->sednMail();
|
$mail->sednMail();
|
||||||
|
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ class AccountStateController extends Controller {
|
|||||||
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
||||||
|
|
||||||
|
|
||||||
$mail = new AccountStateMail(['model' => $model]);
|
$mail = new AccountStateMail(['model' => $model,'controller' => $this]);
|
||||||
$mail->sednMail();
|
$mail->sednMail();
|
||||||
|
|
||||||
return $this->redirect ( [
|
return $this->redirect ( [
|
||||||
|
|||||||
@ -12,6 +12,8 @@ use yii\web\BadRequestHttpException;
|
|||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use yii\filters\VerbFilter;
|
use yii\filters\VerbFilter;
|
||||||
use yii\filters\AccessControl;
|
use yii\filters\AccessControl;
|
||||||
|
use common\models\User;
|
||||||
|
use common\components\Helper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Site controller
|
* Site controller
|
||||||
@ -88,12 +90,31 @@ class SiteController extends Controller
|
|||||||
|
|
||||||
$model = new LoginForm();
|
$model = new LoginForm();
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->login()) {
|
if ($model->load(Yii::$app->request->post()) && $model->login()) {
|
||||||
|
|
||||||
|
|
||||||
// return $this->goBack();
|
// return $this->goBack();
|
||||||
return $this->redirect(['account/select']);
|
return $this->redirect(['account/select']);
|
||||||
} else {
|
} else {
|
||||||
return $this->render('login', ['model' => $model,]);
|
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.
|
* Logs out the current user.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user