Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* User model
*
* @property integer $id
* @property string $nikname
* @property string $username
* @property string $password_hash
* @property string $password_reset_token
Expand Down
36 changes: 36 additions & 0 deletions console/migrations/m170109_205520_create_myuser_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

use yii\db\Migration;

/**
* Handles the creation of table `user`.
*/
class m170109_205520_create_myuser_table extends Migration
{
/**
* @inheritdoc
*/
public function up()
{
$this->createTable('user', [
'id' => $this->primaryKey(),
'nikname' => $this->string()->notNull(),
'username' => $this->string()->notNull(),
'auth_key' => $this->string(32)->notNull(),
'password_hash' => $this->string()->notNull(),
'password_reset_token' => $this->string()->unique(),
'email' => $this->string()->notNull()->unique(),
'status' => $this->smallInteger()->notNull()->defaultValue(10),
'created_at' => $this->integer()->notNull(),
'updated_at' => $this->integer()->notNull(),
]);
}

/**
* @inheritdoc
*/
public function down()
{
$this->dropTable('user');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

use yii\db\Migration;

/**
* Handles adding nikname to table `user`.
*/
class m170110_105113_add_nikname_column_to_user_table extends Migration
{
/**
* @inheritdoc
*/
public function up()
{
$this->addColumn('user', 'nikname', $this->string());
}

/**
* @inheritdoc
*/
public function down()
{
$this->dropColumn('user', 'nikname');
}
}
2 changes: 0 additions & 2 deletions frontend/config/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@
'errorHandler' => [
'errorAction' => 'site/error',
],
/*
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
],
],
*/
],
'params' => $params,
];
60 changes: 57 additions & 3 deletions frontend/controllers/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,32 @@ public function behaviors()
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['logout', 'signup'],
'only' => ['logout', 'signup', 'office', 'forgest', 'special-callback', 'new-callback'],
'rules' => [
[
'actions' => ['signup'],
'actions' => ['signup', 'forgest'],
'allow' => true,
'roles' => ['?'],
],
[
'actions' => ['logout'],
'actions' => ['logout','office'],
'allow' => true,
'roles' => ['@'],
],
[
'actions' => ['special-callback'],
'allow' => true,
'matchCallback' => function ($rule, $action) {
return date('d-m') === '10-01';
}
],
[
'actions' => ['new-callback'],
'allow' => true,
'denyCallback' => function ($rule, $action) {
$this->redirect('new-callback');
}
]
],
],
'verbs' => [
Expand Down Expand Up @@ -75,6 +89,46 @@ public function actionIndex()
return $this->render('index');
}

/**
* Office for logged user
*
* @return mixed
*/
public function actionOffice()
{
return $this->render('office');
}

/**
*Only for gest user
*
* @return mixed
*/
public function actionForgest()
{
return $this->render('forgest');
}

/**
* matchCallback
*
* @return string
*/
public function actionSpecialCallback()
{
return $this->render('matchcallback');
}

/**
* aciton
*
* @return string
*/
public function actionDenyCallback()
{
return $this->render('new-callback');
}

/**
* Logs in a user.
*
Expand Down
10 changes: 10 additions & 0 deletions frontend/models/Office.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace frontend\models;

use yii\base\Model;

class Office extends Model
{

}
6 changes: 6 additions & 0 deletions frontend/models/SignupForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
class SignupForm extends Model
{
public $nikname;
public $username;
public $email;
public $password;
Expand All @@ -20,6 +21,10 @@ class SignupForm extends Model
public function rules()
{
return [
['nikname', 'trim'],
['nikname', 'required'],
['nikname', 'string', 'min' => 2, 'max' => 255],

['username', 'trim'],
['username', 'required'],
['username', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This username has already been taken.'],
Expand Down Expand Up @@ -48,6 +53,7 @@ public function signup()
}

$user = new User();
$user->nikname = $this->nikname;
$user->username = $this->username;
$user->email = $this->email;
$user->setPassword($this->password);
Expand Down
1 change: 1 addition & 0 deletions frontend/views/layouts/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']],
['label' => 'Office', 'url' => ['/site/office']],
];
if (Yii::$app->user->isGuest) {
$menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']];
Expand Down
6 changes: 6 additions & 0 deletions frontend/views/site/forgest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

use yii\helpers\Html;
?>

<h2>This page only for Gest user</h2>
7 changes: 7 additions & 0 deletions frontend/views/site/matchcallback.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

use yii\helpers\Html;

?>

<h2>matchCallback</h2>
6 changes: 6 additions & 0 deletions frontend/views/site/new-callback.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
use yii\helpers\Html;

?>

<h2>DenyCallback</h2>
8 changes: 8 additions & 0 deletions frontend/views/site/office.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;

?>

<h1>Office</h1>
4 changes: 3 additions & 1 deletion frontend/views/site/signup.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
<div class="col-lg-5">
<?php $form = ActiveForm::begin(['id' => 'form-signup']); ?>

<?= $form->field($model, 'username')->textInput(['autofocus' => true]) ?>
<?= $form->field($model, 'nikname')->textInput(['autofocus' => true]) ?>

<?= $form->field($model, 'username')->textInput() ?>

<?= $form->field($model, 'email') ?>

Expand Down
11 changes: 11 additions & 0 deletions frontend/web/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Options +FollowSymLinks
IndexIgnore */*

RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php