Merge branch 'master' into account_sessions

This commit is contained in:
SleepWalker 2016-06-04 15:59:01 +03:00
commit e18f6a08b0
8 changed files with 33 additions and 229 deletions

View File

@ -10,7 +10,7 @@ node_modules
*/config/*-local.php
# Все временные файлы
runtime
*/runtime
# Их по идее и не должно образовываться, но мало ли
api/web/assets
# Их по идее их не должно образовываться, но мало ли
*/web/assets

2
.env Normal file
View File

@ -0,0 +1,2 @@
XDEBUG_CONFIG=remote_host=192.168.99.1
PHP_IDE_CONFIG=serverName=docker

View File

@ -33,14 +33,20 @@ RUN apt-get update \
# Поставим xdebug отдельно, т.к. потом его потенциально придётся отсюда убирать
RUN yes | pecl install xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini
&& echo "xdebug.default_enable=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_handler=dbgp" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_mode=req" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_connect_back=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.cli_color=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.var_display_max_depth=10" >> /usr/local/etc/php/conf.d/xdebug.ini
# Next composer and global composer package, as their versions may change from time to time
RUN curl -sS https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer.phar \
&& composer.phar global require --no-progress "fxp/composer-asset-plugin:~1.1.4" \
&& composer.phar global require --no-progress "hirak/prestissimo:~0.2.2"
&& composer.phar global require --no-progress "fxp/composer-asset-plugin:~1.1.4" "hirak/prestissimo:~0.2.2"
COPY ./docker/php/composer.sh /usr/local/bin/composer
RUN chmod a+x /usr/local/bin/composer
@ -60,5 +66,4 @@ RUN mkdir -p api/runtime api/web/assets console/runtime \
&& chown www-data:www-data api/runtime api/web/assets console/runtime
# Expose everything under /var/www (vendor + html)
# This is only required for the nginx setup
VOLUME ["/var/www"]

View File

@ -11,6 +11,7 @@ return [
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'api\controllers',
'params' => $params,
'components' => [
'user' => [
'class' => \api\components\User\Component::class,
@ -28,9 +29,6 @@ return [
],
],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'request' => [
'baseUrl' => '/api',
],
@ -40,7 +38,7 @@ return [
'rules' => require __DIR__ . '/routes.php',
],
'reCaptcha' => [
'class' => 'api\components\ReCaptcha\Component',
'class' => \api\components\ReCaptcha\Component::class,
],
'response' => [
'format' => \yii\web\Response::FORMAT_JSON,
@ -50,5 +48,4 @@ return [
'grantTypes' => ['authorization_code'],
],
],
'params' => $params,
];

View File

@ -1,190 +0,0 @@
<?php
namespace api\controllers;
use api\models\ContactForm;
use api\models\PasswordResetRequestForm;
use api\models\ResetPasswordForm;
use api\models\SignupForm;
use Yii;
use yii\base\InvalidParamException;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\web\BadRequestHttpException;
/**
* Site controller
*/
class SiteController extends \yii\web\Controller
{
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['logout', 'signup'],
'rules' => [
[
'actions' => ['signup'],
'allow' => true,
'roles' => ['?'],
],
[
'actions' => ['logout'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}
/**
* @inheritdoc
*/
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
],
];
}
/**
* Displays homepage.
*
* @return mixed
*/
public function actionIndex()
{
return $this->render('index');
}
/**
* Logs out the current user.
*
* @return mixed
*/
public function actionLogout()
{
Yii::$app->user->logout();
return $this->goHome();
}
/**
* Displays contact page.
*
* @return mixed
*/
public function actionContact()
{
$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.');
} else {
Yii::$app->session->setFlash('error', 'There was an error sending email.');
}
return $this->refresh();
} else {
return $this->render('contact', [
'model' => $model,
]);
}
}
/**
* Displays about page.
*
* @return mixed
*/
public function actionAbout()
{
return $this->render('about');
}
/**
* Signs user up.
*
* @return mixed
*/
public function actionSignup()
{
$model = new SignupForm();
if ($model->load(Yii::$app->request->post())) {
if ($user = $model->signup()) {
if (Yii::$app->getUser()->login($user)) {
return $this->goHome();
}
}
}
return $this->render('signup', [
'model' => $model,
]);
}
/**
* Requests password reset.
*
* @return mixed
*/
public function actionRequestPasswordReset()
{
$model = new PasswordResetRequestForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->sendEmail()) {
Yii::$app->session->setFlash('success', 'Check your email for further instructions.');
return $this->goHome();
} else {
Yii::$app->session->setFlash('error', 'Sorry, we are unable to reset password for email provided.');
}
}
return $this->render('requestPasswordResetToken', [
'model' => $model,
]);
}
/**
* Resets password.
*
* @param string $token
* @return mixed
* @throws BadRequestHttpException
*/
public function actionResetPassword($token)
{
try {
$model = new ResetPasswordForm($token);
} catch (InvalidParamException $e) {
throw new BadRequestHttpException($e->getMessage());
}
if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) {
Yii::$app->session->setFlash('success', 'New password was saved.');
return $this->goHome();
}
return $this->render('resetPassword', [
'model' => $model,
]);
}
}

View File

@ -1,13 +1,18 @@
version: '2'
services:
app:
build: .
expose:
- "9000"
links:
- db
- redis
- rabbitmq
depends_on:
- app-console-account-queue
volumes:
- ./:/var/www/html/
env_file: .env
environment:
ENABLE_ENV_FILE: 1
ENABLE_LOCALCONF: 1
@ -21,16 +26,6 @@ services:
volumes_from:
- app
app:
build: .
expose:
- "9000"
volumes:
- ./:/var/www/html/
environment:
ENABLE_ENV_FILE: 1
ENABLE_LOCALCONF: 1
node-dev-server:
build: ./frontend
ports:

View File

@ -19,11 +19,7 @@ http {
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
keepalive_timeout 10;
server {
listen 80;
@ -50,6 +46,7 @@ http {
fastcgi_pass app:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SERVER_NAME $host;
}
# Раздача статики для frontend
@ -58,10 +55,6 @@ http {
expires max;
access_log off;
}
location ~* \.(htaccess|htpasswd|svn|git) {
deny all;
}
}
}

2
environments/docker/.env Normal file
View File

@ -0,0 +1,2 @@
XDEBUG_CONFIG=remote_host=192.168.99.1
PHP_IDE_CONFIG=serverName=docker