コード例 #1
0
ファイル: Signup.php プロジェクト: GAMITG/yii2-app-angular
 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         if ($user->save()) {
             return $user;
         }
     }
     return null;
 }
コード例 #2
0
ファイル: Login.php プロジェクト: deesoft/yii2-app-single
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = User::findByUsername($this->username);
     }
     return $this->_user;
 }
コード例 #3
0
ファイル: WebUser.php プロジェクト: xexys/xca-backend
 public function getModel()
 {
     if (!$this->isGuest && $this->_model === null) {
         $this->_model = User::model()->with('role')->findByPk($this->id);
     }
     return $this->_model;
 }
コード例 #4
0
 public function actionIndex()
 {
     $model = new BasketModel();
     if ($_POST && $model->load($_POST)) {
         $order = new Order(['user_id' => $model->userId, 'status' => 'new', 'created' => new Expression('NOW()')]);
         $this->basket->createOrder($order);
         $this->redirect(['payment/pay', 'orderId' => $order->id]);
     }
     $params = ['basket' => $this->basket, 'users' => ArrayHelper::map(User::find()->all(), 'id', 'name'), 'model' => $model];
     return $this->render('index', $params);
 }
コード例 #5
0
 /**
  * Creates a form model given a token.
  *
  * @param  string $token
  * @param  array $config name-value pairs that will be used to initialize the object properties
  * @throws \yii\base\InvalidParamException if token is empty or not valid
  */
 public function __construct($token, $config = [])
 {
     if (empty($token) || !is_string($token)) {
         throw new InvalidParamException('Password reset token cannot be blank.');
     }
     $this->_user = User::findByPasswordResetToken($token);
     if (!$this->_user) {
         throw new InvalidParamException('Wrong password reset token.');
     }
     parent::__construct($config);
 }
コード例 #6
0
 /**
  * Sends an email with a link, for resetting the password.
  *
  * @return boolean whether the email was send
  */
 public function sendEmail()
 {
     /* @var $user User */
     $user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $this->email]);
     if ($user) {
         if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
             $user->generatePasswordResetToken();
         }
         if ($user->save()) {
             return \Yii::$app->mailer->compose(['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user])->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot'])->setTo($this->email)->setSubject('Password reset for ' . \Yii::$app->name)->send();
         }
     }
     return false;
 }
コード例 #7
0
ファイル: UserIdentity.php プロジェクト: xexys/xca-backend
 public function authenticate()
 {
     //$user = User::model()->notDeleted()->findByAttributes(array('email'=>$this->email));
     $user = User::model()->find(array('condition' => "email=:email", 'params' => array(':email' => $this->email)));
     if ($user === null) {
         $this->errorCode = self::ERROR_EMAIL_INVALID;
     } elseif ($user->password !== $this->password) {
         // TODO: Сделать проверку по хешу
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } else {
         $this->_id = $user->id;
         $this->errorCode = self::ERROR_NONE;
     }
     return !$this->errorCode;
 }
コード例 #8
0
ファイル: Payment.php プロジェクト: Hrachkhachatryan/yii2
 /**
  * #return \yii\db\ActiveRelation
  */
 public function getUser()
 {
     return $this->hasOne(\app\models\ar\User::className(), ['id' => 'user_id']);
 }
コード例 #9
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUser()
 {
     return $this->hasOne(User::className(), ['id' => 'id']);
 }
コード例 #10
0
 /**
  * This method is called after each cest class test method, even if test failed.
  * @param \Codeception\Event\TestEvent $event
  */
 public function _after($event)
 {
     User::deleteAll(['email' => '*****@*****.**', 'username' => 'tester']);
 }
コード例 #11
0
ファイル: index.php プロジェクト: Hrachkhachatryan/yii2
<?php

use opus\ecom\widgets\GridView;
?>
<div class="site-index">

    <div class="body-content">

        <div class="row">
            <div class="col-lg-3">
                <h2>Users</h2>

                <?php 
echo GridView::widget(['dataProvider' => new \yii\data\ActiveDataProvider(['query' => \app\models\ar\User::find(), 'pagination' => false]), 'columns' => ['id', 'name']]);
?>
            </div>
            <div class="col-lg-8">
                <h2>Products</h2>

                <?php 
echo GridView::widget(['dataProvider' => new \yii\data\ActiveDataProvider(['query' => \app\models\ar\Product::find(), 'pagination' => false]), 'columns' => ['id', 'name', 'price:price', ['class' => \yii\grid\ActionColumn::className(), 'buttons' => ['add-product' => function ($url) {
    return \yii\helpers\Html::a('Add to basket', $url);
}], 'template' => '{add-product}', 'controller' => 'basket']]]);
?>

                <h2>Discounts</h2>
                <?php 
echo GridView::widget(['dataProvider' => new \yii\data\ActiveDataProvider(['query' => \app\models\ar\Discount::find(), 'pagination' => false]), 'columns' => ['label', ['class' => \yii\grid\ActionColumn::className(), 'buttons' => ['add-discount' => function ($url) {
    return \yii\helpers\Html::a('Apply discount', $url);
}], 'template' => '{add-discount}', 'controller' => 'basket']]]);
?>