Browse Source

Gestion des redirections après connexion / inscription

dev
Guillaume Bourgeois 5 years ago
parent
commit
aee3b50b02
5 changed files with 78 additions and 45 deletions
  1. +5
    -0
      common/models/UserProducer.php
  2. +23
    -2
      frontend/controllers/SiteController.php
  3. +3
    -0
      frontend/models/SignupForm.php
  4. +43
    -41
      frontend/web/css/screen.css
  5. +4
    -2
      frontend/web/sass/screen.scss

+ 5
- 0
common/models/UserProducer.php View File

@@ -86,6 +86,11 @@ class UserProducer extends ActiveRecordCommon
];
}
public function getProducer()
{
return $this->hasOne(Producer::className(), ['id' => 'id_producer']);
}
/**
* Retourne les options de base nécessaires à la fonction de recherche.
*

+ 23
- 2
frontend/controllers/SiteController.php View File

@@ -189,7 +189,17 @@ class SiteController extends FrontendController
return $this->redirect($returnUrl);
}
else {
return $this->goBack();
$userProducerArray = UserProducer::find()
->with(['producer'])
->where(['id_user' => User::getCurrentId(), 'active' => 1, 'bookmark' => 1])
->all() ;
if($userProducerArray && is_array($userProducerArray) && count($userProducerArray) == 1) {
return $this->redirect(Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $userProducerArray[0]->producer->slug ]));
}
else {
return $this->goBack();
}
}
} else {
return $this->render('@frontend/views/site/login', [
@@ -243,7 +253,18 @@ class SiteController extends FrontendController
if ($model->load(Yii::$app->request->post())) {
if ($user = $model->signup()) {
if (Yii::$app->getUser()->login($user)) {
$this->redirect(['site/index']);
if($model->option_user_producer == 'producer') {
$this->redirect(Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index']));
}
else {
$producer = Producer::findOne($model->id_producer) ;
if($producer) {
$this->redirect(Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index','slug_producer' => $producer->slug]));
}
else {
$this->redirect(['site/index']);
}
}
}
}
}

+ 3
- 0
frontend/models/SignupForm.php View File

@@ -163,6 +163,9 @@ class SignupForm extends Model
}
}
}],
['id_producer', 'required', 'message' => 'Champs obligatoire', 'when' => function($model) {
return $this->option_user_producer == 'user' ;
}],
['code', 'required', 'message' => 'Champs obligatoire', 'when' => function($model) {
$producer = Producer::findOne($this->id_producer);
if ($producer) {

+ 43
- 41
frontend/web/css/screen.css View File

@@ -682,25 +682,27 @@ ul li {
}

/* login */
/* line 687, ../sass/screen.scss */
/* line 689, ../sass/screen.scss */
.site-login .col-lg-5 {
margin: 0px auto;
float: none;
max-width: 500px;
}

/* signup */
/* line 695, ../sass/screen.scss */
/* line 698, ../sass/screen.scss */
.modal-backdrop {
z-index: 999;
}

/* line 700, ../sass/screen.scss */
/* line 703, ../sass/screen.scss */
.site-signup .col-lg-5 {
margin: 0px auto;
float: none;
max-width: 500px;
}

/* line 710, ../sass/screen.scss */
/* line 712, ../sass/screen.scss */
#modal-cgv .modal-body h2 {
margin-bottom: 5px;
padding-bottom: 0px;
@@ -708,37 +710,37 @@ ul li {
margin-top: 0px;
}

/* line 720, ../sass/screen.scss */
/* line 722, ../sass/screen.scss */
#form-signup #user-producer {
margin-bottom: 30px;
}
/* line 725, ../sass/screen.scss */
/* line 727, ../sass/screen.scss */
#form-signup #signupform-id_producer option:disabled {
font-weight: bold;
color: black;
}
/* line 731, ../sass/screen.scss */
/* line 733, ../sass/screen.scss */
#form-signup #champs-producer {
display: none;
}
/* line 735, ../sass/screen.scss */
/* line 737, ../sass/screen.scss */
#form-signup #buttons-signup {
margin-top: 30px;
}

/* line 740, ../sass/screen.scss */
/* line 742, ../sass/screen.scss */
#col-left {
padding: 0px;
z-index: 15;
}
/* line 744, ../sass/screen.scss */
/* line 746, ../sass/screen.scss */
#col-left .affix {
width: 25%;
border-right: solid 1px #e0e0e0;
background-color: #FAFAFA;
height: 100%;
}
/* line 751, ../sass/screen.scss */
/* line 753, ../sass/screen.scss */
#col-left #link-home {
text-decoration: none;
font-size: 22px;
@@ -747,28 +749,28 @@ ul li {
padding: 10px;
background-color: white;
}
/* line 759, ../sass/screen.scss */
/* line 761, ../sass/screen.scss */
#col-left #link-home img {
height: 50px;
margin-bottom: 5px;
float: left;
}
/* line 765, ../sass/screen.scss */
/* line 767, ../sass/screen.scss */
#col-left #link-home .text {
padding-left: 62px;
}
/* line 768, ../sass/screen.scss */
/* line 770, ../sass/screen.scss */
#col-left #link-home .text .bap {
font-family: "comfortaalight";
font-size: 24px;
}
/* line 773, ../sass/screen.scss */
/* line 775, ../sass/screen.scss */
#col-left #link-home .text .plateforme {
font-size: 17px;
font-family: "myriadpro-light";
color: #FF7F00;
}
/* line 781, ../sass/screen.scss */
/* line 783, ../sass/screen.scss */
#col-left h2 {
font-family: "myriadpro-regular";
color: black;
@@ -776,37 +778,37 @@ ul li {
margin-bottom: 10px;
padding: 15px 0px 5px 15px;
}
/* line 789, ../sass/screen.scss */
/* line 791, ../sass/screen.scss */
#col-left #links {
background-color: white;
margin-bottom: 20px;
}
/* line 795, ../sass/screen.scss */
/* line 797, ../sass/screen.scss */
#col-left #links ul li a {
text-align: center;
border-right: solid 1px #e0e0e0;
}
/* line 799, ../sass/screen.scss */
/* line 801, ../sass/screen.scss */
#col-left #links ul li a:hover {
background-color: #FF7F00;
color: white;
}
/* line 805, ../sass/screen.scss */
/* line 807, ../sass/screen.scss */
#col-left #links ul li:last-child a {
border-right: 0px none;
}
/* line 815, ../sass/screen.scss */
/* line 817, ../sass/screen.scss */
#col-left #producers nav.nav-producers ul li a {
padding-left: 50px;
height: 40px;
}
/* line 821, ../sass/screen.scss */
/* line 823, ../sass/screen.scss */
#col-left #producers nav.nav-producers ul li.active a {
background-color: #FF7F00;
position: relative;
color: white;
}
/* line 826, ../sass/screen.scss */
/* line 828, ../sass/screen.scss */
#col-left #producers nav.nav-producers ul li.active a:after {
right: -40px;
top: 50%;
@@ -821,18 +823,18 @@ ul li {
border-width: 20px;
margin-top: -20px;
}
/* line 845, ../sass/screen.scss */
/* line 847, ../sass/screen.scss */
#col-left ul {
list-style-type: none;
margin: 0px;
padding: 0px;
}
/* line 849, ../sass/screen.scss */
/* line 851, ../sass/screen.scss */
#col-left ul li {
margin: 0px;
padding: 0px;
}
/* line 852, ../sass/screen.scss */
/* line 854, ../sass/screen.scss */
#col-left ul li a {
text-decoration: none;
font-family: "comfortaaregular";
@@ -843,18 +845,18 @@ ul li {
display: block;
color: black;
}
/* line 862, ../sass/screen.scss */
/* line 864, ../sass/screen.scss */
#col-left ul li a span.name, #col-left ul li a span.wording {
display: none;
}
/* line 869, ../sass/screen.scss */
/* line 871, ../sass/screen.scss */
#col-left p {
padding: 20px;
padding-top: 0px;
color: gray;
}

/* line 877, ../sass/screen.scss */
/* line 879, ../sass/screen.scss */
#content .header-title {
height: 79px;
padding: 20px 20px;
@@ -869,7 +871,7 @@ ul li {
-webkit-box-shadow: 0px 0px 8px #e0e0e0;
box-shadow: 0px 0px 8px #e0e0e0;
}
/* line 889, ../sass/screen.scss */
/* line 891, ../sass/screen.scss */
#content .header-title h1 {
color: black;
font-family: "myriadpro-regular";
@@ -877,7 +879,7 @@ ul li {
font-size: 25px;
text-transform: uppercase;
}
/* line 897, ../sass/screen.scss */
/* line 899, ../sass/screen.scss */
#content .header-title h2 {
color: gray;
text-transform: none;
@@ -886,16 +888,16 @@ ul li {
line-height: 20px;
}

/* line 908, ../sass/screen.scss */
/* line 910, ../sass/screen.scss */
.header-producer {
z-index: 1;
}
/* line 910, ../sass/screen.scss */
/* line 912, ../sass/screen.scss */
.header-producer #block-main-img {
height: 144px;
overflow: hidden;
}
/* line 914, ../sass/screen.scss */
/* line 916, ../sass/screen.scss */
.header-producer #block-main-img #main-img {
width: 100%;
height: auto;
@@ -905,7 +907,7 @@ ul li {
-webkit-border-radius: 0px;
border-radius: 0px;
}
/* line 923, ../sass/screen.scss */
/* line 925, ../sass/screen.scss */
.header-producer h1 {
font-family: "comfortaaregular";
text-align: center;
@@ -913,23 +915,23 @@ ul li {
top: 30px;
left: 40px;
}
/* line 930, ../sass/screen.scss */
/* line 932, ../sass/screen.scss */
.header-producer h1 span {
background-color: rgba(255, 255, 255, 0.8);
padding: 10px 30px;
border: dotted 1px black;
}

/* line 941, ../sass/screen.scss */
/* line 943, ../sass/screen.scss */
nav#menu-producer {
border-bottom: solid 1px #e0e0e0;
}
/* line 945, ../sass/screen.scss */
/* line 947, ../sass/screen.scss */
nav#menu-producer ul li {
padding: 0px;
margin: 0px;
}
/* line 948, ../sass/screen.scss */
/* line 950, ../sass/screen.scss */
nav#menu-producer ul li a {
border-right: solid 1px #e0e0e0;
text-decoration: none;
@@ -937,13 +939,13 @@ nav#menu-producer ul li a {
-webkit-border-radius: 0px;
border-radius: 0px;
}
/* line 953, ../sass/screen.scss */
/* line 955, ../sass/screen.scss */
nav#menu-producer ul li a:hover {
background-color: #FF7F00;
color: white;
}

/* line 963, ../sass/screen.scss */
/* line 965, ../sass/screen.scss */
.site-contact .col-lg-5 {
margin: 0px auto;
float: none;

+ 4
- 2
frontend/web/sass/screen.scss View File

@@ -683,10 +683,13 @@ ul {

/* login */

$max-width-form: 500px ;

.site-login {
.col-lg-5 {
margin: 0px auto ;
float: none ;
max-width: $max-width-form ;
}
}

@@ -700,9 +703,8 @@ ul {
.col-lg-5 {
margin: 0px auto ;
float: none ;
max-width: $max-width-form ;
}
}

#modal-cgv {

Loading…
Cancel
Save