Browse Source

Gestion des redirections après connexion / inscription

refactoring
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

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

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

return $this->redirect($returnUrl); return $this->redirect($returnUrl);
} }
else { 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 { } else {
return $this->render('@frontend/views/site/login', [ return $this->render('@frontend/views/site/login', [
if ($model->load(Yii::$app->request->post())) { if ($model->load(Yii::$app->request->post())) {
if ($user = $model->signup()) { if ($user = $model->signup()) {
if (Yii::$app->getUser()->login($user)) { 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

} }
} }
}], }],
['id_producer', 'required', 'message' => 'Champs obligatoire', 'when' => function($model) {
return $this->option_user_producer == 'user' ;
}],
['code', 'required', 'message' => 'Champs obligatoire', 'when' => function($model) { ['code', 'required', 'message' => 'Champs obligatoire', 'when' => function($model) {
$producer = Producer::findOne($this->id_producer); $producer = Producer::findOne($this->id_producer);
if ($producer) { if ($producer) {

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

} }


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


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


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


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


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


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


/* line 877, ../sass/screen.scss */
/* line 879, ../sass/screen.scss */
#content .header-title { #content .header-title {
height: 79px; height: 79px;
padding: 20px 20px; padding: 20px 20px;
-webkit-box-shadow: 0px 0px 8px #e0e0e0; -webkit-box-shadow: 0px 0px 8px #e0e0e0;
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 { #content .header-title h1 {
color: black; color: black;
font-family: "myriadpro-regular"; font-family: "myriadpro-regular";
font-size: 25px; font-size: 25px;
text-transform: uppercase; text-transform: uppercase;
} }
/* line 897, ../sass/screen.scss */
/* line 899, ../sass/screen.scss */
#content .header-title h2 { #content .header-title h2 {
color: gray; color: gray;
text-transform: none; text-transform: none;
line-height: 20px; line-height: 20px;
} }


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


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


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

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



/* login */ /* login */


$max-width-form: 500px ;

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


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


#modal-cgv { #modal-cgv {

Loading…
Cancel
Save