123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <?php
- namespace app\models;
- use Yii;
- use \yii\db\ActiveRecord;
- use \yii\web\IdentityInterface;
- /**
- * This is the model class for table "testUsers".
- *
- * @property integer $id
- * @property string $username
- * @property string $forename
- * @property string $surname
- * @property string $email
- * @property string $lang
- * @property string $phone
- * @property string $accessToken
- * @property string $authKey
- * @property string $password
- */
- class TestUsers extends ActiveRecord implements IdentityInterface
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'testUsers';
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['username', 'accessToken', 'authKey', 'password'], 'required'],
- [['username', 'forename', 'surname', 'email', 'phone'], 'string', 'max' => 32],
- [['accessToken', 'authKey', 'password'], 'string', 'max' => 100],
- [['lang'], 'string', 'max' => 10],
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => Yii::t('app', 'ID'),
- 'username' => Yii::t('app', 'Username'),
- 'forename' => Yii::t('app', 'Forename'),
- 'surname' => Yii::t('app', 'Surname'),
- 'email' => Yii::t('app', 'Email'),
- 'phone' => Yii::t('app', 'Phone'),
- 'lang' => Yii::t('app', 'Language'),
- 'accessToken' => Yii::t('app', 'Access Token'),
- 'authKey' => Yii::t('app', 'Auth Key'),
- 'password' => Yii::t('app', 'Password'),
- ];
- }
- /**
- * @return string
- */
- public function getAuthKey()
- {
- return $this->authKey;
- }
- /**
- * @return int
- */
- public function getId()
- {
- return $this->id;
- }
- public function validateAuthKey($authKey){
- return $this->authKey === $authKey;
- }
- public static function findIdentity($id){
- return self::findOne($id);
- }
- public static function findIdentityByAccessToken($token, $type = null){
- //throw new \yii\base\NotSupportedException();
- return self::findOne(['access_token' => $token]);
- }
- public static function findByUsername($username){
- return self::findOne(['username'=>$username]);
- }
- public function validatePassword($password){
- return $this->password === $password;
- }
- /**
- * @param string $phone
- */
- public function setPhone($phone)
- {
- $this->phone = $phone;
- }
- public function setEmail($email)
- {
- $this->email = $email;
- }
- /**
- * @return string
- */
- public function getEmail()
- {
- return $this->email;
- }
- /**
- * @return string
- */
- public function getPhone()
- {
- return $this->phone;
- }
- }
|