implement mobile devices in reception

This commit is contained in:
2022-02-19 14:51:58 +01:00
parent 9fb0485066
commit 34fca82e7d
13 changed files with 834 additions and 185 deletions

View File

@@ -18,8 +18,9 @@ use yii\web\NotFoundHttpException;
class LoginForm extends Model
{
// cardnumber
public $username;
public $password;
public $cardNumber;
public $deviceId;
public $deviceName;
public $customer;
@@ -30,9 +31,9 @@ class LoginForm extends Model
{
return [
// username and password are both required
[['username', 'password'], 'required'],
// password is validated by validatePassword()
['password', 'validatePassword'],
[['cardNumber', 'deviceId','deviceName'], 'required'],
// cardNumber is validated by validatePassword()
['cardNumber', 'validateCardNumber'],
];
}
@@ -52,7 +53,7 @@ class LoginForm extends Model
* @param array $params the additional name-value pairs given in the rule
* @throws \yii\base\InvalidConfigException
*/
public function validatePassword($attribute, $params)
public function validateCardNumber($attribute, $params)
{
if ($this->hasErrors()) {
/** @var \common\models\Customer $user */
@@ -72,7 +73,7 @@ class LoginForm extends Model
if ($this->customer === null) {
$mobileDeviceManager = new MobileDeviceManager();
$mobileDevice = $mobileDeviceManager->loginOrCreate($this->username, $this->password);
$mobileDevice = $mobileDeviceManager->loginOrCreate($this->cardNumber, $this->deviceId, $this->deviceName);
/** @var Customer */
$this->customer = Customer::find()->andWhere([
'id_customer_card' => $mobileDevice->id_card