Commit 429f17c19a355257a1ee8b4d97b292ca49f37c95

Authored by Administrator
1 parent d4c9a267

проапдейтил роли

common/models/Customer.php
@@ -74,12 +74,7 @@ class Customer extends \yii\db\ActiveRecord implements \yii\web\IdentityInterfac @@ -74,12 +74,7 @@ class Customer extends \yii\db\ActiveRecord implements \yii\web\IdentityInterfac
74 ->exists()) 74 ->exists())
75 $this->addError('username','Такой пользователь уже есть.'); 75 $this->addError('username','Такой пользователь уже есть.');
76 } 76 }
77 -  
78 - public function sendMsg(){  
79 77
80 - Mailer::widget(['type' => 'registration', 'subject'=> 'Спасибо за регистрацию', 'email' => $this->username ]);  
81 -  
82 - }  
83 78
84 public function afterSave($insert, $changedAttributes) 79 public function afterSave($insert, $changedAttributes)
85 { 80 {
@@ -93,30 +88,28 @@ class Customer extends \yii\db\ActiveRecord implements \yii\web\IdentityInterfac @@ -93,30 +88,28 @@ class Customer extends \yii\db\ActiveRecord implements \yii\web\IdentityInterfac
93 } 88 }
94 $auth->assign($role, $this->id); 89 $auth->assign($role, $this->id);
95 90
96 - if($this->isNewRecord){  
97 - $this->sendMsg();  
98 - } 91 +
99 } 92 }
100 93
101 public function beforeSave($insert) { 94 public function beforeSave($insert) {
102 95
103 96
104 - $this->date_time = new \yii\db\Expression('NOW()');  
105 - 97 + $this->date_time = new \yii\db\Expression('NOW()');
  98 +
106 /** 99 /**
107 - if($image = UploadedFile::getInstance($this,'image')){  
108 - 100 + if($image = UploadedFile::getInstance($this,'image')){
  101 +
109 $this->deleteImage($this->old_image); 102 $this->deleteImage($this->old_image);
110 //$this->image = $image; 103 //$this->image = $image;
111 $this->image = time() . '_' . rand(1, 1000) . '.' . $image->extension; 104 $this->image = time() . '_' . rand(1, 1000) . '.' . $image->extension;
112 $image->saveAs('upload/profile/'.$this->image); 105 $image->saveAs('upload/profile/'.$this->image);
113 - 106 +
114 $resizeObj = new resize('upload/profile/'.$this->image); 107 $resizeObj = new resize('upload/profile/'.$this->image);
115 $resizeObj -> resizeImage(240, 240, 'crop'); 108 $resizeObj -> resizeImage(240, 240, 'crop');
116 $resizeObj -> saveImage('upload/profile/ico/'.$this->image, 100); 109 $resizeObj -> saveImage('upload/profile/ico/'.$this->image, 100);
117 }elseif(!empty($this->old_image)) $this->image = $this->old_image; 110 }elseif(!empty($this->old_image)) $this->image = $this->old_image;
118 - **/  
119 - 111 + **/
  112 +
120 return parent::beforeSave($insert); 113 return parent::beforeSave($insert);
121 } 114 }
122 115
frontend/controllers/RegController.php
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace frontend\controllers; 3 namespace frontend\controllers;
4 4
  5 +use common\components\Mailer;
5 use Yii; 6 use Yii;
6 use yii\web\Controller; 7 use yii\web\Controller;
7 use yii\filters\AccessControl; 8 use yii\filters\AccessControl;
@@ -57,6 +58,7 @@ class RegController extends Controller @@ -57,6 +58,7 @@ class RegController extends Controller
57 $modelLogin->username = $model->username; 58 $modelLogin->username = $model->username;
58 $modelLogin->password = $model->password; 59 $modelLogin->password = $model->password;
59 $modelLogin->login(); 60 $modelLogin->login();
  61 + Mailer::widget(['type' => 'registration', 'subject'=> 'Спасибо за регистрацию', 'email' => $this->username ]);
60 $this->redirect(['/iam']); 62 $this->redirect(['/iam']);
61 } 63 }
62 64