@@ -36,6 +36,8 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
termes. | |||
*/ | |||
$serverName = $_SERVER['SERVER_NAME'] ; | |||
return [ | |||
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', | |||
'components' => [ | |||
@@ -45,7 +47,7 @@ return [ | |||
'enableAutoLogin' => true, | |||
'identityCookie' => [ | |||
'name' => 'laboiteapain', | |||
'domain' => '.'.Yii::getAlias('@domainName'), | |||
'domain' => (($serverName != 'localhost') ? '.' : '') . Yii::getAlias('@domainName'), | |||
'path' => '/', | |||
] | |||
], | |||
@@ -53,7 +55,7 @@ return [ | |||
'class' => 'yii\web\Session', | |||
'name' => 'PHPLABOITEAPAINSESSID', | |||
'cookieParams' => [ | |||
'domain' => '.'.Yii::getAlias('@domainName'), | |||
'domain' => (($serverName != 'localhost') ? '.' : '') . Yii::getAlias('@domainName'), | |||
'httpOnly' => true, | |||
], | |||
], |
@@ -292,7 +292,7 @@ class User extends ActiveRecordCommon implements IdentityInterface | |||
} | |||
$query = (new Query()) | |||
->select(['user.id AS user_id', 'user.name', 'user.lastname', 'user.phone', 'user.email', 'user.created_at', 'user.date_last_connection', 'user_producer.*']) | |||
->select(['user.id AS user_id', 'user.name', 'user.lastname', 'user.phone', 'user.email', 'user.created_at', 'CAST(FROM_UNIXTIME(user.created_at) AS date) as date_created_at','user.date_last_connection', 'user_producer.*']) | |||
->from('user'); | |||
$active = (isset($params['inactive']) && $params['inactive']) ? 0 : 1 ; |
@@ -65,7 +65,7 @@ use dosamigos\leaflet\widgets\Map; | |||
*/ | |||
class SiteController extends FrontendController | |||
{ | |||
/** | |||
* @inheritdoc | |||
*/ | |||
@@ -179,7 +179,7 @@ class SiteController extends FrontendController | |||
public function actionLogin() | |||
{ | |||
if (!\Yii::$app->user->isGuest) { | |||
return Yii::$app->getResponse()->redirect(['order/index']); | |||
return Yii::$app->getResponse()->redirect(['site/index']); | |||
} | |||
$model = new LoginForm(); |
@@ -260,42 +260,33 @@ class SignupForm extends Model | |||
$user->setPassword($this->password); | |||
$user->generateAuthKey(); | |||
if ($user->save()) { | |||
// on ajoute l'établissement sélectionnée par l'user en favoris | |||
if ($this->option_user_producer == 'user') { | |||
if ($this->id_producer) { | |||
$producer = Producer::find()->where(['id' => $this->id_producer])->one(); | |||
if ($producer) { | |||
Producer::addUser($user->id, $this->id_producer) ; | |||
if ($this->option_user_producer == 'user' && $this->id_producer) { | |||
$producer = Producer::find()->where(['id' => $this->id_producer])->one(); | |||
// envoi d'un email à l'utilisateur | |||
Yii::$app->mailer->compose( | |||
[ | |||
'html' => 'signup-html', | |||
'text' => 'signup-text' | |||
], | |||
[ | |||
'user' => $user, | |||
'producer' => $producer | |||
]) | |||
->setTo($user->email) | |||
->setFrom([Yii::$app->params['adminEmail'] => 'La boîte à pain']) | |||
->setSubject('[La boîte à pain] Inscription') | |||
->send(); | |||
} | |||
if ($producer) { | |||
Producer::addUser($user->id, $this->id_producer) ; | |||
// envoi d'un email à l'utilisateur | |||
Yii::$app->mailer->compose( | |||
[ | |||
'html' => 'signup-html', | |||
'text' => 'signup-text' | |||
], | |||
[ | |||
'user' => $user, | |||
'producer' => $producer | |||
]) | |||
->setTo($user->email) | |||
->setFrom([Yii::$app->params['adminEmail'] => 'La boîte à pain']) | |||
->setSubject('[La boîte à pain] Inscription') | |||
->send(); | |||
} | |||
} | |||
if ($this->option_user_producer == 'user') { | |||
$userProducer = new UserProducer; | |||
$userProducer->id_producer = $producer->id; | |||
$userProducer->id_user = $user->id; | |||
$userProducer->credit = 0; | |||
$userProducer->active = 1; | |||
$userProducer->save(); | |||
} | |||
return $user; | |||
} | |||
} |
@@ -256,7 +256,7 @@ class User extends Component | |||
Yii::info($log, __METHOD__); | |||
$this->afterLogin($identity, false, $duration); | |||
} | |||
return !$this->getIsGuest(); | |||
} | |||