use mobiledevice as login object for mobile api

This commit is contained in:
2022-02-22 14:41:16 +01:00
parent 356fc1f0fd
commit 530accd8bf
8 changed files with 90 additions and 71 deletions

View File

@@ -119,15 +119,4 @@ class MobileDeviceManager extends BaseObject
}
public function isMobileDeviceActivatedByIdCard($idCard){
if ( !isset($idCard)){
return false;
}
$device = MobileDevice::find()->andWhere(['id_card' => $idCard])->one();
if ( !isset($device)){
return false;
}
return isset($device->activated_at);
}
}

View File

@@ -3,8 +3,10 @@
namespace common\models;
use Yii;
use yii\base\NotSupportedException;
use yii\behaviors\TimestampBehavior;
use yii\helpers\ArrayHelper;
use yii\web\IdentityInterface;
/**
* This is the model class for table "mobile_device".
@@ -18,7 +20,7 @@ use yii\helpers\ArrayHelper;
* @property string $created_at
* @property string $updated_at
*/
class MobileDevice extends \yii\db\ActiveRecord
class MobileDevice extends \yii\db\ActiveRecord implements IdentityInterface
{
const STATUS_ACTIVE = 'active';
@@ -95,4 +97,31 @@ class MobileDevice extends \yii\db\ActiveRecord
}
return $result;
}
public static function findIdentity($id)
{
self::findOne(['id' => $id]);
}
public static function findIdentityByAccessToken($token, $type = null)
{
throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
}
public function getId()
{
return $this->id;
}
public function getAuthKey()
{
throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
}
public function validateAuthKey($authKey)
{
throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
}
}