%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 49.231.201.246 / Your IP : 216.73.216.149 Web Server : Apache/2.4.18 (Ubuntu) System : Linux 246 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : root ( 0) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,pcntl_exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/water/vendor/dektrium/yii2-user/models/ |
Upload File : |
<?php /* * This file is part of the Dektrium project. * * (c) Dektrium project <http://github.com/dektrium/> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace dektrium\user\models; use dektrium\user\traits\ModuleTrait; use Yii; use yii\db\ActiveRecord; use yii\helpers\Url; /** * Token Active Record model. * * @property integer $user_id * @property string $code * @property integer $created_at * @property integer $type * @property string $url * @property bool $isExpired * @property User $user * * @author Dmitry Erofeev <dmeroff@gmail.com> */ class Token extends ActiveRecord { use ModuleTrait; const TYPE_CONFIRMATION = 0; const TYPE_RECOVERY = 1; const TYPE_CONFIRM_NEW_EMAIL = 2; const TYPE_CONFIRM_OLD_EMAIL = 3; /** * @return \yii\db\ActiveQuery */ public function getUser() { return $this->hasOne($this->module->modelMap['User'], ['id' => 'user_id']); } /** * @return string */ public function getUrl() { switch ($this->type) { case self::TYPE_CONFIRMATION: $route = '/user/registration/confirm'; break; case self::TYPE_RECOVERY: $route = '/user/recovery/reset'; break; case self::TYPE_CONFIRM_NEW_EMAIL: case self::TYPE_CONFIRM_OLD_EMAIL: $route = '/user/settings/confirm'; break; default: throw new \RuntimeException(); } return Url::to([$route, 'id' => $this->user_id, 'code' => $this->code], true); } /** * @return bool Whether token has expired. */ public function getIsExpired() { switch ($this->type) { case self::TYPE_CONFIRMATION: case self::TYPE_CONFIRM_NEW_EMAIL: case self::TYPE_CONFIRM_OLD_EMAIL: $expirationTime = $this->module->confirmWithin; break; case self::TYPE_RECOVERY: $expirationTime = $this->module->recoverWithin; break; default: throw new \RuntimeException(); } return ($this->created_at + $expirationTime) < time(); } /** @inheritdoc */ public function beforeSave($insert) { if ($insert) { static::deleteAll(['user_id' => $this->user_id, 'type' => $this->type]); $this->setAttribute('created_at', time()); $this->setAttribute('code', Yii::$app->security->generateRandomString()); } return parent::beforeSave($insert); } /** @inheritdoc */ public static function tableName() { return '{{%token}}'; } /** @inheritdoc */ public static function primaryKey() { return ['user_id', 'code', 'type']; } }