コード例 #1
0
ファイル: OrderShipping.php プロジェクト: rcjusto/simplestore
 /**
  * @return null|DestinationAccount
  */
 public function getDestinationAccount()
 {
     if (!empty($this->shipping_email)) {
         $model = DestinationAccount::findOne($this->shipping_email);
         if (is_null($model)) {
             $model = new DestinationAccount();
             $model->email = $this->shipping_email;
         }
         if (empty($model->password)) {
             $model->password = Yii::$app->getSecurity()->generateRandomString(8);
         }
         $model->active = 1;
         $model->save();
         return $model;
     } else {
         return null;
     }
 }
コード例 #2
0
 public function loginDestination()
 {
     /** @var DestinationAccount $model */
     $model = DestinationAccount::find()->where(['email' => $this->username])->one();
     if (!is_null($model) && $model->password == $this->password) {
         return $model;
     } else {
         $this->addError('password', Yii::t('app', 'Incorrect User or Password'));
         return null;
     }
 }
コード例 #3
0
 public function actionForgotPassword()
 {
     $this->layout = 'login';
     $model = new AdminLoginForm();
     $show = 'login';
     $username = Yii::$app->request->post('username');
     /** @var DestinationAccount $destination */
     $destination = DestinationAccount::find()->where(['email' => $username])->one();
     if (!is_null($destination)) {
         $destination->generateEmailForgotPassword();
         StoreUtils::sendPendingEmails();
         $model->username = $destination->email;
         Yii::$app->session->setFlash('general-info', Yii::t('app', 'An email with the information you requested was successfully sent to {email}', ['email' => $destination->email]));
     } else {
         $show = 'password';
         Yii::$app->session->setFlash('password-error', Yii::t('app', 'The email address you provided could not be found'));
     }
     return $this->render('login', ['model' => $model, 'show' => $show]);
 }