Pārlūkot izejas kodu

[Backend] Paramètres : correctifs option "Commander en tant que visiteur" #310

Possibilité de s'inscrire avec l'adresse email d'un compte 'guest' : création d'un compte 'individual'
refactoring
Guillaume Bourgeois pirms 2 gadiem
vecāks
revīzija
2e457b37ed
4 mainītis faili ar 17 papildinājumiem un 4 dzēšanām
  1. +1
    -1
      backend/views/producer/update.php
  2. +2
    -2
      common/models/User.php
  3. +1
    -0
      frontend/controllers/SiteController.php
  4. +13
    -1
      frontend/models/SignupForm.php

+ 1
- 1
backend/views/producer/update.php Parādīt failu

@@ -290,7 +290,7 @@ $this->addBreadcrumb($this->getTitle()) ;
1 => 'Oui'
], []); ?>

<?= $form->field($model, 'option_allow_order_guest')
<?php echo $form->field($model, 'option_allow_order_guest')
->dropDownList([
0 => 'Non',
1 => 'Oui'

+ 2
- 2
common/models/User.php Parādīt failu

@@ -226,10 +226,10 @@ class User extends ActiveRecordCommon implements IdentityInterface
public function verifyEmail($attribute, $params)
{
if($this->id) {
$user = User::find()->where("email LIKE :email AND id != :id")->params(array(':email' => '%' . $this->email . '%', ':id' => $this->id))->one();
$user = User::find()->where("email LIKE :email AND type != :guest AND id != :id")->params(array(':email' => '%' . $this->email . '%', ':id' => $this->id, ':guest' => 'guest'))->one();
}
else {
$user = User::find()->where("email LIKE :email")->params(array(':email' => '%' . $this->email . '%'))->one();
$user = User::find()->where("email LIKE :email AND type != :guest")->params(array(':email' => '%' . $this->email . '%', ':guest' => 'guest'))->one();
}

if ($user) {

+ 1
- 0
frontend/controllers/SiteController.php Parādīt failu

@@ -252,6 +252,7 @@ class SiteController extends FrontendController
$model = new SignupForm();
if ($model->load(Yii::$app->request->post())) {
$user = $model->signup();

if ($user) {
if (Yii::$app->getUser()->login($user)) {
if ($model->option_user_producer == 'producer') {

+ 13
- 1
frontend/models/SignupForm.php Parādīt failu

@@ -80,7 +80,19 @@ class SignupForm extends Model
['email', 'filter', 'filter' => 'trim'],
['email', 'required', 'message' => 'Champs obligatoire'],
['email', 'email'],
['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'Cet email est déjà utilisé'],
['email', function($attribute, $params) {
$email = $this->$attribute;

$userExist = User::searchOne([
'type' => 'individual',
'email' => $email
]);

if($userExist) {
$this->addError($attribute, 'Cet email est déjà utilisé.');
}
}],
//['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'Cet email est déjà utilisé'],
[['name', 'lastname', 'phone'], 'required', 'message' => 'Champs obligatoire'],
[['name', 'lastname', 'phone', 'option_user_producer'], 'string', 'min' => 2, 'max' => 255],
['password', 'required', 'message' => 'Champs obligatoire'],

Notiek ielāde…
Atcelt
Saglabāt