Quellcode durchsuchen

Refactoring services #885

refactoring
Guillaume vor 1 Jahr
Ursprung
Commit
1bc40a71fb
4 geänderte Dateien mit 13 neuen und 15 gelöschten Zeilen
  1. +1
    -1
      common/controllers/CommonController.php
  2. +2
    -2
      common/logic/User/User/Service/UserBuilder.php
  3. +9
    -11
      frontend/controllers/SiteController.php
  4. +1
    -1
      frontend/forms/SignupForm.php

+ 1
- 1
common/controllers/CommonController.php Datei anzeigen

@@ -76,7 +76,7 @@ class CommonController extends \yii\web\Controller
return Yii::$app->urlManagerBackend;
}

public function getUserCurrent(): User
public function getUserCurrent(): ?User
{
return Yii::$app->user->identity;
}

+ 2
- 2
common/logic/User/User/Service/UserBuilder.php Datei anzeigen

@@ -25,8 +25,8 @@ class UserBuilder extends AbstractBuilder

public function initPassword(User $user, string $password)
{
$user->setPassword($password);
$user->generateAuthKey();
$this->setPassword($user, $password);
$this->generateAuthKey($user);
}

public function initProducer(User $user, Producer $producer)

+ 9
- 11
frontend/controllers/SiteController.php Datei anzeigen

@@ -254,19 +254,17 @@ class SiteController extends FrontendController
if ($model->load(Yii::$app->request->post())) {
$user = $model->signup();

if ($user) {
if ($this->getUser()->login($user)) {
if ($model->isProducer()) {
$this->redirect(Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index']));
if ($user && $this->getUserCurrent()->login($user)) {
if ($model->isProducer()) {
$this->redirect(Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index']));
}
else {
$producer = $producerManager->findOneProducerById($model->id_producer);
if ($producer) {
$this->redirect($this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug]));
}
else {
$producer = $producerManager->findOneProducerById($model->id_producer);
if ($producer) {
$this->redirect($this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug]));
}
else {
$this->redirect(['site/index']);
}
$this->redirect(['site/index']);
}
}
}

+ 1
- 1
frontend/forms/SignupForm.php Datei anzeigen

@@ -251,7 +251,7 @@ class SignupForm extends Model

if ($user->save() && $producer) {
// Liaison User / Producer
$producerManager->addUser($user->id, $idProducer);
$producerManager->addUser($user, $producer);

// Envoi d'un email de bienvenue à l'utilisateur
if ($this->isCustomer()) {

Laden…
Abbrechen
Speichern