add customerapi + customer auth

This commit is contained in:
2019-09-30 19:33:48 +02:00
committed by Roland Schneider
parent 51788f2194
commit 9aee187d11
55 changed files with 21835 additions and 14 deletions

View File

@@ -149,6 +149,8 @@ class CustomerController extends \backend\controllers\BackendController
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException
* @throws \yii\base\InvalidConfigException
*/
public function actionUpdate($id)
{

View File

@@ -33,13 +33,12 @@ use common\models\Customer;
*/
class CustomerUpdate extends \common\models\Customer
{
public $password_plain;
public $cardNumber;
public $partnerCardNumber;
public $password_plain;
public $password_repeat;
/**
* @inheritdoc
*/
@@ -57,7 +56,9 @@ class CustomerUpdate extends \common\models\Customer
// [['cardNumber'], 'required' ],
// [['cardNumber'], 'string', 'max' => 10],
// [['cardNumber'], 'validateCustomerCard' ],
[['password_plain' ] ,'string','min' =>6 ],
[['partnerCardNumber'], 'string', 'max' => 10],
[['partnerCardNumber'], 'validatePartnerCard' ],
@@ -78,7 +79,7 @@ class CustomerUpdate extends \common\models\Customer
],
[['password_plain','password_repeat'], 'string', 'max' => 32],
[['password_plain' ], 'string', 'max' => 32],
[['sex'], 'integer'],
@@ -113,5 +114,22 @@ class CustomerUpdate extends \common\models\Customer
public function validatePartnerCard($a,$p){
// Customer::find()->andWhere( [$this->cardNumber )
}
/**
* @param bool $insert
* @return bool
* @throws \yii\base\Exception
* @throws \yii\base\InvalidConfigException
*/
public function beforeSave($insert)
{
$result = parent::beforeSave($insert);
if ($result && !empty($this->password_plain)) {
$this->setPassword($this->password_plain);
return true;
}
return $result;
}
}

View File

@@ -84,4 +84,4 @@ class UserUpdate extends User {
$role = $am->getRole($this->role);
Yii::$app->authManager->assign($role, $this->id);
}
}
}

View File

@@ -69,6 +69,11 @@ use kartik\widgets\DatePicker;
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'password_plain')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'description')->textarea(['maxlength' => true]) ?>
</div>