Reformat code te be PSR-2 compatible
This commit is contained in:
parent
a85ef65aba
commit
93cc82c4bf
@ -15,15 +15,15 @@ use yii\web\AssetBundle;
|
|||||||
*/
|
*/
|
||||||
class AppAsset extends AssetBundle
|
class AppAsset extends AssetBundle
|
||||||
{
|
{
|
||||||
public $basePath = '@webroot';
|
public $basePath = '@webroot';
|
||||||
public $baseUrl = '@web';
|
public $baseUrl = '@web';
|
||||||
public $css = [
|
public $css = [
|
||||||
'css/site.css',
|
'css/site.css',
|
||||||
];
|
];
|
||||||
public $js = [
|
public $js = [
|
||||||
];
|
];
|
||||||
public $depends = [
|
public $depends = [
|
||||||
'yii\web\YiiAsset',
|
'yii\web\YiiAsset',
|
||||||
'yii\bootstrap\BootstrapAsset',
|
'yii\bootstrap\BootstrapAsset',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,12 @@ use yii\console\Controller;
|
|||||||
*/
|
*/
|
||||||
class HelloController extends Controller
|
class HelloController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* This command echoes what you have entered as the message.
|
* This command echoes what you have entered as the message.
|
||||||
* @param string $message the message to be echoed.
|
* @param string $message the message to be echoed.
|
||||||
*/
|
*/
|
||||||
public function actionIndex($message = 'hello world')
|
public function actionIndex($message = 'hello world')
|
||||||
{
|
{
|
||||||
echo $message . "\n";
|
echo $message . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,24 +6,24 @@ $params = require(__DIR__ . '/params.php');
|
|||||||
$db = require(__DIR__ . '/db.php');
|
$db = require(__DIR__ . '/db.php');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => 'basic-console',
|
'id' => 'basic-console',
|
||||||
'basePath' => dirname(__DIR__),
|
'basePath' => dirname(__DIR__),
|
||||||
'preload' => ['log'],
|
'preload' => ['log'],
|
||||||
'controllerNamespace' => 'app\commands',
|
'controllerNamespace' => 'app\commands',
|
||||||
'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'),
|
'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'),
|
||||||
'components' => [
|
'components' => [
|
||||||
'cache' => [
|
'cache' => [
|
||||||
'class' => 'yii\caching\FileCache',
|
'class' => 'yii\caching\FileCache',
|
||||||
],
|
],
|
||||||
'log' => [
|
'log' => [
|
||||||
'targets' => [
|
'targets' => [
|
||||||
[
|
[
|
||||||
'class' => 'yii\log\FileTarget',
|
'class' => 'yii\log\FileTarget',
|
||||||
'levels' => ['error', 'warning'],
|
'levels' => ['error', 'warning'],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'db' => $db,
|
'db' => $db,
|
||||||
],
|
],
|
||||||
'params' => $params,
|
'params' => $params,
|
||||||
];
|
];
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'class' => 'yii\db\Connection',
|
'class' => 'yii\db\Connection',
|
||||||
'dsn' => 'mysql:host=localhost;dbname=yii2basic',
|
'dsn' => 'mysql:host=localhost;dbname=yii2basic',
|
||||||
'username' => 'root',
|
'username' => 'root',
|
||||||
'password' => '',
|
'password' => '',
|
||||||
'charset' => 'utf8',
|
'charset' => 'utf8',
|
||||||
];
|
];
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'adminEmail' => 'admin@example.com',
|
'adminEmail' => 'admin@example.com',
|
||||||
];
|
];
|
||||||
|
@ -4,43 +4,43 @@ $params = require(__DIR__ . '/params.php');
|
|||||||
$db = require(__DIR__ . '/db.php');
|
$db = require(__DIR__ . '/db.php');
|
||||||
|
|
||||||
$config = [
|
$config = [
|
||||||
'id' => 'basic',
|
'id' => 'basic',
|
||||||
'basePath' => dirname(__DIR__),
|
'basePath' => dirname(__DIR__),
|
||||||
'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'),
|
'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'),
|
||||||
'components' => [
|
'components' => [
|
||||||
'cache' => [
|
'cache' => [
|
||||||
'class' => 'yii\caching\FileCache',
|
'class' => 'yii\caching\FileCache',
|
||||||
],
|
],
|
||||||
'user' => [
|
'user' => [
|
||||||
'identityClass' => 'app\models\User',
|
'identityClass' => 'app\models\User',
|
||||||
'enableAutoLogin' => true,
|
'enableAutoLogin' => true,
|
||||||
],
|
],
|
||||||
'errorHandler' => [
|
'errorHandler' => [
|
||||||
'errorAction' => 'site/error',
|
'errorAction' => 'site/error',
|
||||||
],
|
],
|
||||||
'mail' => [
|
'mail' => [
|
||||||
'class' => 'yii\swiftmailer\Mailer',
|
'class' => 'yii\swiftmailer\Mailer',
|
||||||
'useFileTransport' => true,
|
'useFileTransport' => true,
|
||||||
],
|
],
|
||||||
'log' => [
|
'log' => [
|
||||||
'traceLevel' => YII_DEBUG ? 3 : 0,
|
'traceLevel' => YII_DEBUG ? 3 : 0,
|
||||||
'targets' => [
|
'targets' => [
|
||||||
[
|
[
|
||||||
'class' => 'yii\log\FileTarget',
|
'class' => 'yii\log\FileTarget',
|
||||||
'levels' => ['error', 'warning'],
|
'levels' => ['error', 'warning'],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'db' => $db,
|
'db' => $db,
|
||||||
],
|
],
|
||||||
'params' => $params,
|
'params' => $params,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (YII_ENV_DEV) {
|
if (YII_ENV_DEV) {
|
||||||
// configuration adjustments for 'dev' environment
|
// configuration adjustments for 'dev' environment
|
||||||
$config['preload'][] = 'debug';
|
$config['preload'][] = 'debug';
|
||||||
$config['modules']['debug'] = 'yii\debug\Module';
|
$config['modules']['debug'] = 'yii\debug\Module';
|
||||||
$config['modules']['gii'] = 'yii\gii\Module';
|
$config['modules']['gii'] = 'yii\gii\Module';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $config;
|
return $config;
|
||||||
|
@ -11,84 +11,86 @@ use app\models\ContactForm;
|
|||||||
|
|
||||||
class SiteController extends Controller
|
class SiteController extends Controller
|
||||||
{
|
{
|
||||||
public function behaviors()
|
public function behaviors()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'access' => [
|
'access' => [
|
||||||
'class' => AccessControl::className(),
|
'class' => AccessControl::className(),
|
||||||
'only' => ['logout'],
|
'only' => ['logout'],
|
||||||
'rules' => [
|
'rules' => [
|
||||||
[
|
[
|
||||||
'actions' => ['logout'],
|
'actions' => ['logout'],
|
||||||
'allow' => true,
|
'allow' => true,
|
||||||
'roles' => ['@'],
|
'roles' => ['@'],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'verbs' => [
|
'verbs' => [
|
||||||
'class' => VerbFilter::className(),
|
'class' => VerbFilter::className(),
|
||||||
'actions' => [
|
'actions' => [
|
||||||
'logout' => ['post'],
|
'logout' => ['post'],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actions()
|
public function actions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'error' => [
|
'error' => [
|
||||||
'class' => 'yii\web\ErrorAction',
|
'class' => 'yii\web\ErrorAction',
|
||||||
],
|
],
|
||||||
'captcha' => [
|
'captcha' => [
|
||||||
'class' => 'yii\captcha\CaptchaAction',
|
'class' => 'yii\captcha\CaptchaAction',
|
||||||
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
|
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionIndex()
|
public function actionIndex()
|
||||||
{
|
{
|
||||||
return $this->render('index');
|
return $this->render('index');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionLogin()
|
public function actionLogin()
|
||||||
{
|
{
|
||||||
if (!\Yii::$app->user->isGuest) {
|
if (!\Yii::$app->user->isGuest) {
|
||||||
return $this->goHome();
|
return $this->goHome();
|
||||||
}
|
}
|
||||||
|
|
||||||
$model = new LoginForm();
|
$model = new LoginForm();
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->login()) {
|
if ($model->load(Yii::$app->request->post()) && $model->login()) {
|
||||||
return $this->goBack();
|
return $this->goBack();
|
||||||
} else {
|
} else {
|
||||||
return $this->render('login', [
|
return $this->render('login', [
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionLogout()
|
public function actionLogout()
|
||||||
{
|
{
|
||||||
Yii::$app->user->logout();
|
Yii::$app->user->logout();
|
||||||
return $this->goHome();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function actionContact()
|
return $this->goHome();
|
||||||
{
|
}
|
||||||
$model = new ContactForm();
|
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
|
|
||||||
Yii::$app->session->setFlash('contactFormSubmitted');
|
|
||||||
return $this->refresh();
|
|
||||||
} else {
|
|
||||||
return $this->render('contact', [
|
|
||||||
'model' => $model,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function actionAbout()
|
public function actionContact()
|
||||||
{
|
{
|
||||||
return $this->render('about');
|
$model = new ContactForm();
|
||||||
}
|
if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
|
||||||
|
Yii::$app->session->setFlash('contactFormSubmitted');
|
||||||
|
|
||||||
|
return $this->refresh();
|
||||||
|
} else {
|
||||||
|
return $this->render('contact', [
|
||||||
|
'model' => $model,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actionAbout()
|
||||||
|
{
|
||||||
|
return $this->render('about');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,14 +10,14 @@ use yii\helpers\Html;
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=<?= Yii::$app->charset ?>" />
|
<meta http-equiv="Content-Type" content="text/html; charset=<?= Yii::$app->charset ?>" />
|
||||||
<title><?= Html::encode($this->title) ?></title>
|
<title><?= Html::encode($this->title) ?></title>
|
||||||
<?php $this->head() ?>
|
<?php $this->head() ?>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php $this->beginBody() ?>
|
<?php $this->beginBody() ?>
|
||||||
<?= $content ?>
|
<?= $content ?>
|
||||||
<?php $this->endBody() ?>
|
<?php $this->endBody() ?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
<?php $this->endPage() ?>
|
<?php $this->endPage() ?>
|
||||||
|
@ -10,54 +10,55 @@ use yii\base\Model;
|
|||||||
*/
|
*/
|
||||||
class ContactForm extends Model
|
class ContactForm extends Model
|
||||||
{
|
{
|
||||||
public $name;
|
public $name;
|
||||||
public $email;
|
public $email;
|
||||||
public $subject;
|
public $subject;
|
||||||
public $body;
|
public $body;
|
||||||
public $verifyCode;
|
public $verifyCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array the validation rules.
|
* @return array the validation rules.
|
||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// name, email, subject and body are required
|
// name, email, subject and body are required
|
||||||
[['name', 'email', 'subject', 'body'], 'required'],
|
[['name', 'email', 'subject', 'body'], 'required'],
|
||||||
// email has to be a valid email address
|
// email has to be a valid email address
|
||||||
['email', 'email'],
|
['email', 'email'],
|
||||||
// verifyCode needs to be entered correctly
|
// verifyCode needs to be entered correctly
|
||||||
['verifyCode', 'captcha'],
|
['verifyCode', 'captcha'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array customized attribute labels
|
* @return array customized attribute labels
|
||||||
*/
|
*/
|
||||||
public function attributeLabels()
|
public function attributeLabels()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'verifyCode' => 'Verification Code',
|
'verifyCode' => 'Verification Code',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends an email to the specified email address using the information collected by this model.
|
* Sends an email to the specified email address using the information collected by this model.
|
||||||
* @param string $email the target email address
|
* @param string $email the target email address
|
||||||
* @return boolean whether the model passes validation
|
* @return boolean whether the model passes validation
|
||||||
*/
|
*/
|
||||||
public function contact($email)
|
public function contact($email)
|
||||||
{
|
{
|
||||||
if ($this->validate()) {
|
if ($this->validate()) {
|
||||||
Yii::$app->mail->compose()
|
Yii::$app->mail->compose()
|
||||||
->setTo($email)
|
->setTo($email)
|
||||||
->setFrom([$this->email => $this->name])
|
->setFrom([$this->email => $this->name])
|
||||||
->setSubject($this->subject)
|
->setSubject($this->subject)
|
||||||
->setTextBody($this->body)
|
->setTextBody($this->body)
|
||||||
->send();
|
->send();
|
||||||
return true;
|
|
||||||
} else {
|
return true;
|
||||||
return false;
|
} else {
|
||||||
}
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,65 +10,66 @@ use yii\base\Model;
|
|||||||
*/
|
*/
|
||||||
class LoginForm extends Model
|
class LoginForm extends Model
|
||||||
{
|
{
|
||||||
public $username;
|
public $username;
|
||||||
public $password;
|
public $password;
|
||||||
public $rememberMe = true;
|
public $rememberMe = true;
|
||||||
|
|
||||||
private $_user = false;
|
private $_user = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array the validation rules.
|
* @return array the validation rules.
|
||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// username and password are both required
|
// username and password are both required
|
||||||
[['username', 'password'], 'required'],
|
[['username', 'password'], 'required'],
|
||||||
// rememberMe must be a boolean value
|
// rememberMe must be a boolean value
|
||||||
['rememberMe', 'boolean'],
|
['rememberMe', 'boolean'],
|
||||||
// password is validated by validatePassword()
|
// password is validated by validatePassword()
|
||||||
['password', 'validatePassword'],
|
['password', 'validatePassword'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates the password.
|
* Validates the password.
|
||||||
* This method serves as the inline validation for password.
|
* This method serves as the inline validation for password.
|
||||||
*/
|
*/
|
||||||
public function validatePassword()
|
public function validatePassword()
|
||||||
{
|
{
|
||||||
if (!$this->hasErrors()) {
|
if (!$this->hasErrors()) {
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
|
|
||||||
if (!$user || !$user->validatePassword($this->password)) {
|
if (!$user || !$user->validatePassword($this->password)) {
|
||||||
$this->addError('password', 'Incorrect username or password.');
|
$this->addError('password', 'Incorrect username or password.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs in a user using the provided username and password.
|
* Logs in a user using the provided username and password.
|
||||||
* @return boolean whether the user is logged in successfully
|
* @return boolean whether the user is logged in successfully
|
||||||
*/
|
*/
|
||||||
public function login()
|
public function login()
|
||||||
{
|
{
|
||||||
if ($this->validate()) {
|
if ($this->validate()) {
|
||||||
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600*24*30 : 0);
|
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600*24*30 : 0);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds user by [[username]]
|
* Finds user by [[username]]
|
||||||
*
|
*
|
||||||
* @return User|null
|
* @return User|null
|
||||||
*/
|
*/
|
||||||
public function getUser()
|
public function getUser()
|
||||||
{
|
{
|
||||||
if ($this->_user === false) {
|
if ($this->_user === false) {
|
||||||
$this->_user = User::findByUsername($this->username);
|
$this->_user = User::findByUsername($this->username);
|
||||||
}
|
}
|
||||||
return $this->_user;
|
|
||||||
}
|
return $this->_user;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
174
models/User.php
174
models/User.php
@ -4,98 +4,100 @@ namespace app\models;
|
|||||||
|
|
||||||
class User extends \yii\base\Object implements \yii\web\IdentityInterface
|
class User extends \yii\base\Object implements \yii\web\IdentityInterface
|
||||||
{
|
{
|
||||||
public $id;
|
public $id;
|
||||||
public $username;
|
public $username;
|
||||||
public $password;
|
public $password;
|
||||||
public $authKey;
|
public $authKey;
|
||||||
public $accessToken;
|
public $accessToken;
|
||||||
|
|
||||||
private static $users = [
|
private static $users = [
|
||||||
'100' => [
|
'100' => [
|
||||||
'id' => '100',
|
'id' => '100',
|
||||||
'username' => 'admin',
|
'username' => 'admin',
|
||||||
'password' => 'admin',
|
'password' => 'admin',
|
||||||
'authKey' => 'test100key',
|
'authKey' => 'test100key',
|
||||||
'accessToken' => '100-token',
|
'accessToken' => '100-token',
|
||||||
],
|
],
|
||||||
'101' => [
|
'101' => [
|
||||||
'id' => '101',
|
'id' => '101',
|
||||||
'username' => 'demo',
|
'username' => 'demo',
|
||||||
'password' => 'demo',
|
'password' => 'demo',
|
||||||
'authKey' => 'test101key',
|
'authKey' => 'test101key',
|
||||||
'accessToken' => '101-token',
|
'accessToken' => '101-token',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
public static function findIdentity($id)
|
public static function findIdentity($id)
|
||||||
{
|
{
|
||||||
return isset(self::$users[$id]) ? new static(self::$users[$id]) : null;
|
return isset(self::$users[$id]) ? new static(self::$users[$id]) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
public static function findIdentityByAccessToken($token)
|
public static function findIdentityByAccessToken($token)
|
||||||
{
|
{
|
||||||
foreach (self::$users as $user) {
|
foreach (self::$users as $user) {
|
||||||
if ($user['accessToken'] === $token) {
|
if ($user['accessToken'] === $token) {
|
||||||
return new static($user);
|
return new static($user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
return null;
|
||||||
* Finds user by username
|
}
|
||||||
*
|
|
||||||
* @param string $username
|
|
||||||
* @return static|null
|
|
||||||
*/
|
|
||||||
public static function findByUsername($username)
|
|
||||||
{
|
|
||||||
foreach (self::$users as $user) {
|
|
||||||
if (strcasecmp($user['username'], $username) === 0) {
|
|
||||||
return new static($user);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* Finds user by username
|
||||||
*/
|
*
|
||||||
public function getId()
|
* @param string $username
|
||||||
{
|
* @return static|null
|
||||||
return $this->id;
|
*/
|
||||||
}
|
public static function findByUsername($username)
|
||||||
|
{
|
||||||
|
foreach (self::$users as $user) {
|
||||||
|
if (strcasecmp($user['username'], $username) === 0) {
|
||||||
|
return new static($user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
return null;
|
||||||
* @inheritdoc
|
}
|
||||||
*/
|
|
||||||
public function getAuthKey()
|
|
||||||
{
|
|
||||||
return $this->authKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
public function validateAuthKey($authKey)
|
public function getId()
|
||||||
{
|
{
|
||||||
return $this->authKey === $authKey;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates password
|
* @inheritdoc
|
||||||
*
|
*/
|
||||||
* @param string $password password to validate
|
public function getAuthKey()
|
||||||
* @return boolean if password provided is valid for current user
|
{
|
||||||
*/
|
return $this->authKey;
|
||||||
public function validatePassword($password)
|
}
|
||||||
{
|
|
||||||
return $this->password === $password;
|
/**
|
||||||
}
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function validateAuthKey($authKey)
|
||||||
|
{
|
||||||
|
return $this->authKey === $authKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates password
|
||||||
|
*
|
||||||
|
* @param string $password password to validate
|
||||||
|
* @return boolean if password provided is valid for current user
|
||||||
|
*/
|
||||||
|
public function validatePassword($password)
|
||||||
|
{
|
||||||
|
return $this->password === $password;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
166
requirements.php
166
requirements.php
@ -14,10 +14,10 @@
|
|||||||
$frameworkPath = dirname(__FILE__) . '/vendor/yiisoft/yii2';
|
$frameworkPath = dirname(__FILE__) . '/vendor/yiisoft/yii2';
|
||||||
|
|
||||||
if (!is_dir($frameworkPath)) {
|
if (!is_dir($frameworkPath)) {
|
||||||
echo '<h1>Error</h1>';
|
echo '<h1>Error</h1>';
|
||||||
echo '<p><strong>The path to yii framework seems to be incorrect.</strong></p>';
|
echo '<p><strong>The path to yii framework seems to be incorrect.</strong></p>';
|
||||||
echo '<p>You need to install Yii framework via composer or adjust the framework path in file <abbr title="' . __FILE__ . '">' . basename(__FILE__) . '</abbr>.</p>';
|
echo '<p>You need to install Yii framework via composer or adjust the framework path in file <abbr title="' . __FILE__ . '">' . basename(__FILE__) . '</abbr>.</p>';
|
||||||
echo '<p>Please refer to the <abbr title="' . dirname(__FILE__) . '/README.md">README</abbr> on how to install Yii.</p>';
|
echo '<p>Please refer to the <abbr title="' . dirname(__FILE__) . '/README.md">README</abbr> on how to install Yii.</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once($frameworkPath . '/requirements/YiiRequirementChecker.php');
|
require_once($frameworkPath . '/requirements/YiiRequirementChecker.php');
|
||||||
@ -27,84 +27,84 @@ $requirementsChecker = new YiiRequirementChecker();
|
|||||||
* Adjust requirements according to your application specifics.
|
* Adjust requirements according to your application specifics.
|
||||||
*/
|
*/
|
||||||
$requirements = array(
|
$requirements = array(
|
||||||
// Database :
|
// Database :
|
||||||
array(
|
array(
|
||||||
'name' => 'PDO extension',
|
'name' => 'PDO extension',
|
||||||
'mandatory' => true,
|
'mandatory' => true,
|
||||||
'condition' => extension_loaded('pdo'),
|
'condition' => extension_loaded('pdo'),
|
||||||
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
|
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'name' => 'PDO SQLite extension',
|
'name' => 'PDO SQLite extension',
|
||||||
'mandatory' => false,
|
'mandatory' => false,
|
||||||
'condition' => extension_loaded('pdo_sqlite'),
|
'condition' => extension_loaded('pdo_sqlite'),
|
||||||
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
|
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
|
||||||
'memo' => 'Required for SQLite database.',
|
'memo' => 'Required for SQLite database.',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'name' => 'PDO MySQL extension',
|
'name' => 'PDO MySQL extension',
|
||||||
'mandatory' => false,
|
'mandatory' => false,
|
||||||
'condition' => extension_loaded('pdo_mysql'),
|
'condition' => extension_loaded('pdo_mysql'),
|
||||||
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
|
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
|
||||||
'memo' => 'Required for MySQL database.',
|
'memo' => 'Required for MySQL database.',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'name' => 'PDO PostgreSQL extension',
|
'name' => 'PDO PostgreSQL extension',
|
||||||
'mandatory' => false,
|
'mandatory' => false,
|
||||||
'condition' => extension_loaded('pdo_pgsql'),
|
'condition' => extension_loaded('pdo_pgsql'),
|
||||||
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
|
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
|
||||||
'memo' => 'Required for PostgreSQL database.',
|
'memo' => 'Required for PostgreSQL database.',
|
||||||
),
|
),
|
||||||
// Cache :
|
// Cache :
|
||||||
array(
|
array(
|
||||||
'name' => 'Memcache extension',
|
'name' => 'Memcache extension',
|
||||||
'mandatory' => false,
|
'mandatory' => false,
|
||||||
'condition' => extension_loaded('memcache') || extension_loaded('memcached'),
|
'condition' => extension_loaded('memcache') || extension_loaded('memcached'),
|
||||||
'by' => '<a href="http://www.yiiframework.com/doc/api/CMemCache">CMemCache</a>',
|
'by' => '<a href="http://www.yiiframework.com/doc/api/CMemCache">CMemCache</a>',
|
||||||
'memo' => extension_loaded('memcached') ? 'To use memcached set <a href="http://www.yiiframework.com/doc/api/CMemCache#useMemcached-detail">CMemCache::useMemcached</a> to <code>true</code>.' : ''
|
'memo' => extension_loaded('memcached') ? 'To use memcached set <a href="http://www.yiiframework.com/doc/api/CMemCache#useMemcached-detail">CMemCache::useMemcached</a> to <code>true</code>.' : ''
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'name' => 'APC extension',
|
'name' => 'APC extension',
|
||||||
'mandatory' => false,
|
'mandatory' => false,
|
||||||
'condition' => extension_loaded('apc'),
|
'condition' => extension_loaded('apc'),
|
||||||
'by' => '<a href="http://www.yiiframework.com/doc/api/CApcCache">CApcCache</a>',
|
'by' => '<a href="http://www.yiiframework.com/doc/api/CApcCache">CApcCache</a>',
|
||||||
),
|
),
|
||||||
// Additional PHP extensions :
|
// Additional PHP extensions :
|
||||||
array(
|
array(
|
||||||
'name' => 'Mcrypt extension',
|
'name' => 'Mcrypt extension',
|
||||||
'mandatory' => false,
|
'mandatory' => false,
|
||||||
'condition' => extension_loaded('mcrypt'),
|
'condition' => extension_loaded('mcrypt'),
|
||||||
'by' => '<a href="http://www.yiiframework.com/doc/api/CSecurityManager">CSecurityManager</a>',
|
'by' => '<a href="http://www.yiiframework.com/doc/api/CSecurityManager">CSecurityManager</a>',
|
||||||
'memo' => 'Required by encrypt and decrypt methods.'
|
'memo' => 'Required by encrypt and decrypt methods.'
|
||||||
),
|
),
|
||||||
// PHP ini :
|
// PHP ini :
|
||||||
'phpSafeMode' => array(
|
'phpSafeMode' => array(
|
||||||
'name' => 'PHP safe mode',
|
'name' => 'PHP safe mode',
|
||||||
'mandatory' => false,
|
'mandatory' => false,
|
||||||
'condition' => $requirementsChecker->checkPhpIniOff("safe_mode"),
|
'condition' => $requirementsChecker->checkPhpIniOff("safe_mode"),
|
||||||
'by' => 'File uploading and console command execution',
|
'by' => 'File uploading and console command execution',
|
||||||
'memo' => '"safe_mode" should be disabled at php.ini',
|
'memo' => '"safe_mode" should be disabled at php.ini',
|
||||||
),
|
),
|
||||||
'phpExposePhp' => array(
|
'phpExposePhp' => array(
|
||||||
'name' => 'Expose PHP',
|
'name' => 'Expose PHP',
|
||||||
'mandatory' => false,
|
'mandatory' => false,
|
||||||
'condition' => $requirementsChecker->checkPhpIniOff("expose_php"),
|
'condition' => $requirementsChecker->checkPhpIniOff("expose_php"),
|
||||||
'by' => 'Security reasons',
|
'by' => 'Security reasons',
|
||||||
'memo' => '"expose_php" should be disabled at php.ini',
|
'memo' => '"expose_php" should be disabled at php.ini',
|
||||||
),
|
),
|
||||||
'phpAllowUrlInclude' => array(
|
'phpAllowUrlInclude' => array(
|
||||||
'name' => 'PHP allow url include',
|
'name' => 'PHP allow url include',
|
||||||
'mandatory' => false,
|
'mandatory' => false,
|
||||||
'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"),
|
'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"),
|
||||||
'by' => 'Security reasons',
|
'by' => 'Security reasons',
|
||||||
'memo' => '"allow_url_include" should be disabled at php.ini',
|
'memo' => '"allow_url_include" should be disabled at php.ini',
|
||||||
),
|
),
|
||||||
'phpSmtp' => array(
|
'phpSmtp' => array(
|
||||||
'name' => 'PHP mail SMTP',
|
'name' => 'PHP mail SMTP',
|
||||||
'mandatory' => false,
|
'mandatory' => false,
|
||||||
'condition' => strlen(ini_get('SMTP'))>0,
|
'condition' => strlen(ini_get('SMTP'))>0,
|
||||||
'by' => 'Email sending',
|
'by' => 'Email sending',
|
||||||
'memo' => 'PHP mail SMTP server required',
|
'memo' => 'PHP mail SMTP server required',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
$requirementsChecker->checkYii()->check($requirements)->render();
|
$requirementsChecker->checkYii()->check($requirements)->render();
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
* application configurations shared by all test types
|
* application configurations shared by all test types
|
||||||
*/
|
*/
|
||||||
return [
|
return [
|
||||||
'components' => [
|
'components' => [
|
||||||
'mail' => [
|
'mail' => [
|
||||||
'useFileTransport' => true,
|
'useFileTransport' => true,
|
||||||
],
|
],
|
||||||
'urlManager' => [
|
'urlManager' => [
|
||||||
'showScriptName' => true,
|
'showScriptName' => true,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -3,5 +3,5 @@ namespace Codeception\Module;
|
|||||||
|
|
||||||
class CodeHelper extends \Codeception\Module
|
class CodeHelper extends \Codeception\Module
|
||||||
{
|
{
|
||||||
// here you can define custom methods for CodeGuy
|
// here you can define custom methods for CodeGuy
|
||||||
}
|
}
|
||||||
|
@ -3,5 +3,5 @@ namespace Codeception\Module;
|
|||||||
|
|
||||||
class TestHelper extends \Codeception\Module
|
class TestHelper extends \Codeception\Module
|
||||||
{
|
{
|
||||||
// here you can define custom methods for TestGuy
|
// here you can define custom methods for TestGuy
|
||||||
}
|
}
|
||||||
|
@ -3,5 +3,5 @@ namespace Codeception\Module;
|
|||||||
|
|
||||||
class WebHelper extends \Codeception\Module
|
class WebHelper extends \Codeception\Module
|
||||||
{
|
{
|
||||||
// here you can define custom methods for WebGuy
|
// here you can define custom methods for WebGuy
|
||||||
}
|
}
|
||||||
|
@ -6,5 +6,5 @@ use yii\codeception\BasePage;
|
|||||||
|
|
||||||
class AboutPage extends BasePage
|
class AboutPage extends BasePage
|
||||||
{
|
{
|
||||||
public $route = 'site/about';
|
public $route = 'site/about';
|
||||||
}
|
}
|
||||||
|
@ -6,17 +6,17 @@ use yii\codeception\BasePage;
|
|||||||
|
|
||||||
class ContactPage extends BasePage
|
class ContactPage extends BasePage
|
||||||
{
|
{
|
||||||
public $route = 'site/contact';
|
public $route = 'site/contact';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $contactData
|
* @param array $contactData
|
||||||
*/
|
*/
|
||||||
public function submit(array $contactData)
|
public function submit(array $contactData)
|
||||||
{
|
{
|
||||||
foreach ($contactData as $field => $value) {
|
foreach ($contactData as $field => $value) {
|
||||||
$inputType = $field === 'body' ? 'textarea' : 'input';
|
$inputType = $field === 'body' ? 'textarea' : 'input';
|
||||||
$this->guy->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value);
|
$this->guy->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value);
|
||||||
}
|
}
|
||||||
$this->guy->click('contact-button');
|
$this->guy->click('contact-button');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,16 +6,16 @@ use yii\codeception\BasePage;
|
|||||||
|
|
||||||
class LoginPage extends BasePage
|
class LoginPage extends BasePage
|
||||||
{
|
{
|
||||||
public $route = 'site/login';
|
public $route = 'site/login';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $username
|
* @param string $username
|
||||||
* @param string $password
|
* @param string $password
|
||||||
*/
|
*/
|
||||||
public function login($username, $password)
|
public function login($username, $password)
|
||||||
{
|
{
|
||||||
$this->guy->fillField('input[name="LoginForm[username]"]', $username);
|
$this->guy->fillField('input[name="LoginForm[username]"]', $username);
|
||||||
$this->guy->fillField('input[name="LoginForm[password]"]', $password);
|
$this->guy->fillField('input[name="LoginForm[password]"]', $password);
|
||||||
$this->guy->click('login-button');
|
$this->guy->click('login-button');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ modules:
|
|||||||
- PhpBrowser
|
- PhpBrowser
|
||||||
# you can use WebDriver instead of PhpBrowser to test javascript and ajax.
|
# you can use WebDriver instead of PhpBrowser to test javascript and ajax.
|
||||||
# This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium
|
# This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium
|
||||||
# "restart" option is used by the WebDriver to start each time per test-file new session and cookies,
|
# "restart" option is used by the WebDriver to start each time per test-file new session and cookies,
|
||||||
# it is useful if you want to login in your app in each test.
|
# it is useful if you want to login in your app in each test.
|
||||||
# - WebDriver
|
# - WebDriver
|
||||||
config:
|
config:
|
||||||
|
@ -21,11 +21,11 @@ $I->see('The verification code is incorrect');
|
|||||||
|
|
||||||
$I->amGoingTo('submit contact form with not correct email');
|
$I->amGoingTo('submit contact form with not correct email');
|
||||||
$contactPage->submit([
|
$contactPage->submit([
|
||||||
'name' => 'tester',
|
'name' => 'tester',
|
||||||
'email' => 'tester.email',
|
'email' => 'tester.email',
|
||||||
'subject' => 'test subject',
|
'subject' => 'test subject',
|
||||||
'body' => 'test content',
|
'body' => 'test content',
|
||||||
'verifyCode' => 'testme',
|
'verifyCode' => 'testme',
|
||||||
]);
|
]);
|
||||||
$I->expectTo('see that email adress is wrong');
|
$I->expectTo('see that email adress is wrong');
|
||||||
$I->dontSee('Name cannot be blank', '.help-inline');
|
$I->dontSee('Name cannot be blank', '.help-inline');
|
||||||
@ -36,14 +36,14 @@ $I->dontSee('The verification code is incorrect', '.help-inline');
|
|||||||
|
|
||||||
$I->amGoingTo('submit contact form with correct data');
|
$I->amGoingTo('submit contact form with correct data');
|
||||||
$contactPage->submit([
|
$contactPage->submit([
|
||||||
'name' => 'tester',
|
'name' => 'tester',
|
||||||
'email' => 'tester@example.com',
|
'email' => 'tester@example.com',
|
||||||
'subject' => 'test subject',
|
'subject' => 'test subject',
|
||||||
'body' => 'test content',
|
'body' => 'test content',
|
||||||
'verifyCode' => 'testme',
|
'verifyCode' => 'testme',
|
||||||
]);
|
]);
|
||||||
if (method_exists($I, 'wait')) {
|
if (method_exists($I, 'wait')) {
|
||||||
$I->wait(3); // only for selenium
|
$I->wait(3); // only for selenium
|
||||||
}
|
}
|
||||||
$I->dontSeeElement('#contact-form');
|
$I->dontSeeElement('#contact-form');
|
||||||
$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
|
$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
|
||||||
|
@ -23,7 +23,7 @@ $I->see('Incorrect username or password.');
|
|||||||
$I->amGoingTo('try to login with correct credentials');
|
$I->amGoingTo('try to login with correct credentials');
|
||||||
$loginPage->login('admin', 'admin');
|
$loginPage->login('admin', 'admin');
|
||||||
if (method_exists($I, 'wait')) {
|
if (method_exists($I, 'wait')) {
|
||||||
$I->wait(3); // only for selenium
|
$I->wait(3); // only for selenium
|
||||||
}
|
}
|
||||||
$I->expectTo('see user info');
|
$I->expectTo('see user info');
|
||||||
$I->see('Logout (admin)');
|
$I->see('Logout (admin)');
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return yii\helpers\ArrayHelper::merge(
|
return yii\helpers\ArrayHelper::merge(
|
||||||
require(__DIR__ . '/../../config/web.php'),
|
require(__DIR__ . '/../../config/web.php'),
|
||||||
require(__DIR__ . '/../_config.php'),
|
require(__DIR__ . '/../_config.php'),
|
||||||
[
|
[
|
||||||
'components' => [
|
'components' => [
|
||||||
'db' => [
|
'db' => [
|
||||||
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
|
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return yii\helpers\ArrayHelper::merge(
|
return yii\helpers\ArrayHelper::merge(
|
||||||
require(__DIR__ . '/../../config/console.php'),
|
require(__DIR__ . '/../../config/console.php'),
|
||||||
require(__DIR__ . '/../_config.php'),
|
require(__DIR__ . '/../_config.php'),
|
||||||
[
|
[
|
||||||
'components' => [
|
'components' => [
|
||||||
'db' => [
|
'db' => [
|
||||||
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
|
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -21,11 +21,11 @@ $I->see('The verification code is incorrect');
|
|||||||
|
|
||||||
$I->amGoingTo('submit contact form with not correct email');
|
$I->amGoingTo('submit contact form with not correct email');
|
||||||
$contactPage->submit([
|
$contactPage->submit([
|
||||||
'name' => 'tester',
|
'name' => 'tester',
|
||||||
'email' => 'tester.email',
|
'email' => 'tester.email',
|
||||||
'subject' => 'test subject',
|
'subject' => 'test subject',
|
||||||
'body' => 'test content',
|
'body' => 'test content',
|
||||||
'verifyCode' => 'testme',
|
'verifyCode' => 'testme',
|
||||||
]);
|
]);
|
||||||
$I->expectTo('see that email adress is wrong');
|
$I->expectTo('see that email adress is wrong');
|
||||||
$I->dontSee('Name cannot be blank', '.help-inline');
|
$I->dontSee('Name cannot be blank', '.help-inline');
|
||||||
@ -36,11 +36,11 @@ $I->dontSee('The verification code is incorrect', '.help-inline');
|
|||||||
|
|
||||||
$I->amGoingTo('submit contact form with correct data');
|
$I->amGoingTo('submit contact form with correct data');
|
||||||
$contactPage->submit([
|
$contactPage->submit([
|
||||||
'name' => 'tester',
|
'name' => 'tester',
|
||||||
'email' => 'tester@example.com',
|
'email' => 'tester@example.com',
|
||||||
'subject' => 'test subject',
|
'subject' => 'test subject',
|
||||||
'body' => 'test content',
|
'body' => 'test content',
|
||||||
'verifyCode' => 'testme',
|
'verifyCode' => 'testme',
|
||||||
]);
|
]);
|
||||||
$I->dontSeeElement('#contact-form');
|
$I->dontSeeElement('#contact-form');
|
||||||
$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
|
$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
|
||||||
|
@ -5,13 +5,13 @@ $_SERVER['SCRIPT_FILENAME'] = TEST_ENTRY_FILE;
|
|||||||
$_SERVER['SCRIPT_NAME'] = TEST_ENTRY_URL;
|
$_SERVER['SCRIPT_NAME'] = TEST_ENTRY_URL;
|
||||||
|
|
||||||
return yii\helpers\ArrayHelper::merge(
|
return yii\helpers\ArrayHelper::merge(
|
||||||
require(__DIR__ . '/../../config/web.php'),
|
require(__DIR__ . '/../../config/web.php'),
|
||||||
require(__DIR__ . '/../_config.php'),
|
require(__DIR__ . '/../_config.php'),
|
||||||
[
|
[
|
||||||
'components' => [
|
'components' => [
|
||||||
'db' => [
|
'db' => [
|
||||||
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional',
|
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return yii\helpers\ArrayHelper::merge(
|
return yii\helpers\ArrayHelper::merge(
|
||||||
require(__DIR__ . '/../../config/console.php'),
|
require(__DIR__ . '/../../config/console.php'),
|
||||||
require(__DIR__ . '/../_config.php'),
|
require(__DIR__ . '/../_config.php'),
|
||||||
[
|
[
|
||||||
'components' => [
|
'components' => [
|
||||||
'db' => [
|
'db' => [
|
||||||
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional',
|
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return yii\helpers\ArrayHelper::merge(
|
return yii\helpers\ArrayHelper::merge(
|
||||||
require(__DIR__ . '/../../config/web.php'),
|
require(__DIR__ . '/../../config/web.php'),
|
||||||
require(__DIR__ . '/../_config.php'),
|
require(__DIR__ . '/../_config.php'),
|
||||||
[
|
[
|
||||||
'components' => [
|
'components' => [
|
||||||
'db' => [
|
'db' => [
|
||||||
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit',
|
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return yii\helpers\ArrayHelper::merge(
|
return yii\helpers\ArrayHelper::merge(
|
||||||
require(__DIR__ . '/../../config/console.php'),
|
require(__DIR__ . '/../../config/console.php'),
|
||||||
require(__DIR__ . '/../_config.php'),
|
require(__DIR__ . '/../_config.php'),
|
||||||
[
|
[
|
||||||
'components' => [
|
'components' => [
|
||||||
'db' => [
|
'db' => [
|
||||||
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit',
|
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -7,52 +7,52 @@ use yii\codeception\TestCase;
|
|||||||
|
|
||||||
class ContactFormTest extends TestCase
|
class ContactFormTest extends TestCase
|
||||||
{
|
{
|
||||||
use \Codeception\Specify;
|
use \Codeception\Specify;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
Yii::$app->mail->fileTransportCallback = function ($mailer, $message) {
|
Yii::$app->mail->fileTransportCallback = function ($mailer, $message) {
|
||||||
return 'testing_message.eml';
|
return 'testing_message.eml';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
unlink($this->getMessageFile());
|
unlink($this->getMessageFile());
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testContact()
|
public function testContact()
|
||||||
{
|
{
|
||||||
$model = $this->getMock('app\models\ContactForm', ['validate']);
|
$model = $this->getMock('app\models\ContactForm', ['validate']);
|
||||||
$model->expects($this->once())->method('validate')->will($this->returnValue(true));
|
$model->expects($this->once())->method('validate')->will($this->returnValue(true));
|
||||||
|
|
||||||
$model->attributes = [
|
$model->attributes = [
|
||||||
'name' => 'Tester',
|
'name' => 'Tester',
|
||||||
'email' => 'tester@example.com',
|
'email' => 'tester@example.com',
|
||||||
'subject' => 'very important letter subject',
|
'subject' => 'very important letter subject',
|
||||||
'body' => 'body of current message',
|
'body' => 'body of current message',
|
||||||
];
|
];
|
||||||
|
|
||||||
$model->contact('admin@example.com');
|
$model->contact('admin@example.com');
|
||||||
|
|
||||||
$this->specify('email should be send', function () {
|
$this->specify('email should be send', function () {
|
||||||
expect('email file should exist', file_exists($this->getMessageFile()))->true();
|
expect('email file should exist', file_exists($this->getMessageFile()))->true();
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->specify('message should contain correct data', function () use ($model) {
|
$this->specify('message should contain correct data', function () use ($model) {
|
||||||
$emailMessage = file_get_contents($this->getMessageFile());
|
$emailMessage = file_get_contents($this->getMessageFile());
|
||||||
|
|
||||||
expect('email should contain user name', $emailMessage)->contains($model->name);
|
expect('email should contain user name', $emailMessage)->contains($model->name);
|
||||||
expect('email should contain sender email', $emailMessage)->contains($model->email);
|
expect('email should contain sender email', $emailMessage)->contains($model->email);
|
||||||
expect('email should contain subject', $emailMessage)->contains($model->subject);
|
expect('email should contain subject', $emailMessage)->contains($model->subject);
|
||||||
expect('email should contain body', $emailMessage)->contains($model->body);
|
expect('email should contain body', $emailMessage)->contains($model->body);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getMessageFile()
|
private function getMessageFile()
|
||||||
{
|
{
|
||||||
return Yii::getAlias(Yii::$app->mail->fileTransportPath) . '/testing_message.eml';
|
return Yii::getAlias(Yii::$app->mail->fileTransportPath) . '/testing_message.eml';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,59 +8,60 @@ use app\models\User;
|
|||||||
|
|
||||||
class LoginFormTest extends TestCase
|
class LoginFormTest extends TestCase
|
||||||
{
|
{
|
||||||
use \Codeception\Specify;
|
use \Codeception\Specify;
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
Yii::$app->user->logout();
|
Yii::$app->user->logout();
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLoginNoUser()
|
public function testLoginNoUser()
|
||||||
{
|
{
|
||||||
$model = $this->mockUser(null);
|
$model = $this->mockUser(null);
|
||||||
|
|
||||||
$model->username = 'some_username';
|
$model->username = 'some_username';
|
||||||
$model->password = 'some_password';
|
$model->password = 'some_password';
|
||||||
|
|
||||||
$this->specify('user should not be able to login, when there is no identity', function () use ($model) {
|
$this->specify('user should not be able to login, when there is no identity', function () use ($model) {
|
||||||
expect('model should not login user', $model->login())->false();
|
expect('model should not login user', $model->login())->false();
|
||||||
expect('user should not be logged in', Yii::$app->user->isGuest)->true();
|
expect('user should not be logged in', Yii::$app->user->isGuest)->true();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLoginWrongPassword()
|
public function testLoginWrongPassword()
|
||||||
{
|
{
|
||||||
$model = $this->mockUser(new User);
|
$model = $this->mockUser(new User);
|
||||||
|
|
||||||
$model->username = 'demo';
|
$model->username = 'demo';
|
||||||
$model->password = 'wrong-password';
|
$model->password = 'wrong-password';
|
||||||
|
|
||||||
$this->specify('user should not be able to login with wrong password', function () use ($model) {
|
$this->specify('user should not be able to login with wrong password', function () use ($model) {
|
||||||
expect('model should not login user', $model->login())->false();
|
expect('model should not login user', $model->login())->false();
|
||||||
expect('error message should be set', $model->errors)->hasKey('password');
|
expect('error message should be set', $model->errors)->hasKey('password');
|
||||||
expect('user should not be logged in', Yii::$app->user->isGuest)->true();
|
expect('user should not be logged in', Yii::$app->user->isGuest)->true();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLoginCorrect()
|
public function testLoginCorrect()
|
||||||
{
|
{
|
||||||
$model = $this->mockUser(new User(['password' => 'demo']));
|
$model = $this->mockUser(new User(['password' => 'demo']));
|
||||||
|
|
||||||
$model->username = 'demo';
|
$model->username = 'demo';
|
||||||
$model->password = 'demo';
|
$model->password = 'demo';
|
||||||
|
|
||||||
$this->specify('user should be able to login with correct credentials', function () use ($model) {
|
$this->specify('user should be able to login with correct credentials', function () use ($model) {
|
||||||
expect('model should login user', $model->login())->true();
|
expect('model should login user', $model->login())->true();
|
||||||
expect('error message should not be set', $model->errors)->hasntKey('password');
|
expect('error message should not be set', $model->errors)->hasntKey('password');
|
||||||
expect('user should be logged in', Yii::$app->user->isGuest)->false();
|
expect('user should be logged in', Yii::$app->user->isGuest)->false();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private function mockUser($user)
|
private function mockUser($user)
|
||||||
{
|
{
|
||||||
$loginForm = $this->getMock('app\models\LoginForm', ['getUser']);
|
$loginForm = $this->getMock('app\models\LoginForm', ['getUser']);
|
||||||
$loginForm->expects($this->any())->method('getUser')->will($this->returnValue($user));
|
$loginForm->expects($this->any())->method('getUser')->will($this->returnValue($user));
|
||||||
return $loginForm;
|
|
||||||
}
|
return $loginForm;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,12 @@ use yii\codeception\TestCase;
|
|||||||
|
|
||||||
class UserTest extends TestCase
|
class UserTest extends TestCase
|
||||||
{
|
{
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
// uncomment the following to load fixtures for table tbl_user
|
// uncomment the following to load fixtures for table tbl_user
|
||||||
//$this->loadFixtures(['tbl_user']);
|
//$this->loadFixtures(['tbl_user']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO add test methods here
|
// TODO add test methods here
|
||||||
}
|
}
|
||||||
|
@ -15,53 +15,53 @@ AppAsset::register($this);
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="<?= Yii::$app->language ?>">
|
<html lang="<?= Yii::$app->language ?>">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="<?= Yii::$app->charset ?>"/>
|
<meta charset="<?= Yii::$app->charset ?>"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title><?= Html::encode($this->title) ?></title>
|
<title><?= Html::encode($this->title) ?></title>
|
||||||
<?php $this->head() ?>
|
<?php $this->head() ?>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<?php $this->beginBody() ?>
|
<?php $this->beginBody() ?>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<?php
|
<?php
|
||||||
NavBar::begin([
|
NavBar::begin([
|
||||||
'brandLabel' => 'My Company',
|
'brandLabel' => 'My Company',
|
||||||
'brandUrl' => Yii::$app->homeUrl,
|
'brandUrl' => Yii::$app->homeUrl,
|
||||||
'options' => [
|
'options' => [
|
||||||
'class' => 'navbar-inverse navbar-fixed-top',
|
'class' => 'navbar-inverse navbar-fixed-top',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
echo Nav::widget([
|
echo Nav::widget([
|
||||||
'options' => ['class' => 'navbar-nav navbar-right'],
|
'options' => ['class' => 'navbar-nav navbar-right'],
|
||||||
'items' => [
|
'items' => [
|
||||||
['label' => 'Home', 'url' => ['/site/index']],
|
['label' => 'Home', 'url' => ['/site/index']],
|
||||||
['label' => 'About', 'url' => ['/site/about']],
|
['label' => 'About', 'url' => ['/site/about']],
|
||||||
['label' => 'Contact', 'url' => ['/site/contact']],
|
['label' => 'Contact', 'url' => ['/site/contact']],
|
||||||
Yii::$app->user->isGuest ?
|
Yii::$app->user->isGuest ?
|
||||||
['label' => 'Login', 'url' => ['/site/login']] :
|
['label' => 'Login', 'url' => ['/site/login']] :
|
||||||
['label' => 'Logout (' . Yii::$app->user->identity->username . ')',
|
['label' => 'Logout (' . Yii::$app->user->identity->username . ')',
|
||||||
'url' => ['/site/logout'],
|
'url' => ['/site/logout'],
|
||||||
'linkOptions' => ['data-method' => 'post']],
|
'linkOptions' => ['data-method' => 'post']],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
NavBar::end();
|
NavBar::end();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<?= Breadcrumbs::widget([
|
<?= Breadcrumbs::widget([
|
||||||
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
|
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
|
||||||
]) ?>
|
]) ?>
|
||||||
<?= $content ?>
|
<?= $content ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<p class="pull-left">© My Company <?= date('Y') ?></p>
|
<p class="pull-left">© My Company <?= date('Y') ?></p>
|
||||||
<p class="pull-right"><?= Yii::powered() ?></p>
|
<p class="pull-right"><?= Yii::powered() ?></p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<?php $this->endBody() ?>
|
<?php $this->endBody() ?>
|
||||||
</body>
|
</body>
|
||||||
|
@ -8,11 +8,11 @@ $this->title = 'About';
|
|||||||
$this->params['breadcrumbs'][] = $this->title;
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
?>
|
?>
|
||||||
<div class="site-about">
|
<div class="site-about">
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
This is the About page. You may modify the following file to customize its content:
|
This is the About page. You may modify the following file to customize its content:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<code><?= __FILE__ ?></code>
|
<code><?= __FILE__ ?></code>
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,47 +12,47 @@ $this->title = 'Contact';
|
|||||||
$this->params['breadcrumbs'][] = $this->title;
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
?>
|
?>
|
||||||
<div class="site-contact">
|
<div class="site-contact">
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
<?php if (Yii::$app->session->hasFlash('contactFormSubmitted')): ?>
|
<?php if (Yii::$app->session->hasFlash('contactFormSubmitted')): ?>
|
||||||
|
|
||||||
<div class="alert alert-success">
|
<div class="alert alert-success">
|
||||||
Thank you for contacting us. We will respond to you as soon as possible.
|
Thank you for contacting us. We will respond to you as soon as possible.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Note that if you turn on the Yii debugger, you should be able
|
Note that if you turn on the Yii debugger, you should be able
|
||||||
to view the mail message on the mail panel of the debugger.
|
to view the mail message on the mail panel of the debugger.
|
||||||
<?php if (Yii::$app->mail->useFileTransport): ?>
|
<?php if (Yii::$app->mail->useFileTransport): ?>
|
||||||
Because the application is in development mode, the email is not sent but saved as
|
Because the application is in development mode, the email is not sent but saved as
|
||||||
a file under <code><?= Yii::getAlias(Yii::$app->mail->fileTransportPath) ?></code>.
|
a file under <code><?= Yii::getAlias(Yii::$app->mail->fileTransportPath) ?></code>.
|
||||||
Please configure the <code>useFileTransport</code> property of the <code>mail</code>
|
Please configure the <code>useFileTransport</code> property of the <code>mail</code>
|
||||||
application component to be false to enable email sending.
|
application component to be false to enable email sending.
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
If you have business inquiries or other questions, please fill out the following form to contact us. Thank you.
|
If you have business inquiries or other questions, please fill out the following form to contact us. Thank you.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-5">
|
<div class="col-lg-5">
|
||||||
<?php $form = ActiveForm::begin(['id' => 'contact-form']); ?>
|
<?php $form = ActiveForm::begin(['id' => 'contact-form']); ?>
|
||||||
<?= $form->field($model, 'name') ?>
|
<?= $form->field($model, 'name') ?>
|
||||||
<?= $form->field($model, 'email') ?>
|
<?= $form->field($model, 'email') ?>
|
||||||
<?= $form->field($model, 'subject') ?>
|
<?= $form->field($model, 'subject') ?>
|
||||||
<?= $form->field($model, 'body')->textArea(['rows' => 6]) ?>
|
<?= $form->field($model, 'body')->textArea(['rows' => 6]) ?>
|
||||||
<?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [
|
<?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [
|
||||||
'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',
|
'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',
|
||||||
]) ?>
|
]) ?>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<?= Html::submitButton('Submit', ['class' => 'btn btn-primary', 'name' => 'contact-button']) ?>
|
<?= Html::submitButton('Submit', ['class' => 'btn btn-primary', 'name' => 'contact-button']) ?>
|
||||||
</div>
|
</div>
|
||||||
<?php ActiveForm::end(); ?>
|
<?php ActiveForm::end(); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -13,17 +13,17 @@ $this->title = $name;
|
|||||||
?>
|
?>
|
||||||
<div class="site-error">
|
<div class="site-error">
|
||||||
|
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
<?= nl2br(Html::encode($message)) ?>
|
<?= nl2br(Html::encode($message)) ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The above error occurred while the Web server was processing your request.
|
The above error occurred while the Web server was processing your request.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Please contact us if you think this is a server error. Thank you.
|
Please contact us if you think this is a server error. Thank you.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -6,48 +6,48 @@ $this->title = 'My Yii Application';
|
|||||||
?>
|
?>
|
||||||
<div class="site-index">
|
<div class="site-index">
|
||||||
|
|
||||||
<div class="jumbotron">
|
<div class="jumbotron">
|
||||||
<h1>Congratulations!</h1>
|
<h1>Congratulations!</h1>
|
||||||
|
|
||||||
<p class="lead">You have successfully created your Yii-powered application.</p>
|
<p class="lead">You have successfully created your Yii-powered application.</p>
|
||||||
|
|
||||||
<p><a class="btn btn-lg btn-success" href="http://www.yiiframework.com">Get started with Yii</a></p>
|
<p><a class="btn btn-lg btn-success" href="http://www.yiiframework.com">Get started with Yii</a></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="body-content">
|
<div class="body-content">
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-4">
|
<div class="col-lg-4">
|
||||||
<h2>Heading</h2>
|
<h2>Heading</h2>
|
||||||
|
|
||||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
|
||||||
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
|
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
|
||||||
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
||||||
fugiat nulla pariatur.</p>
|
fugiat nulla pariatur.</p>
|
||||||
|
|
||||||
<p><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation »</a></p>
|
<p><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation »</a></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-4">
|
<div class="col-lg-4">
|
||||||
<h2>Heading</h2>
|
<h2>Heading</h2>
|
||||||
|
|
||||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
|
||||||
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
|
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
|
||||||
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
||||||
fugiat nulla pariatur.</p>
|
fugiat nulla pariatur.</p>
|
||||||
|
|
||||||
<p><a class="btn btn-default" href="http://www.yiiframework.com/forum/">Yii Forum »</a></p>
|
<p><a class="btn btn-default" href="http://www.yiiframework.com/forum/">Yii Forum »</a></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-4">
|
<div class="col-lg-4">
|
||||||
<h2>Heading</h2>
|
<h2>Heading</h2>
|
||||||
|
|
||||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
|
||||||
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
|
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
|
||||||
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
||||||
fugiat nulla pariatur.</p>
|
fugiat nulla pariatur.</p>
|
||||||
|
|
||||||
<p><a class="btn btn-default" href="http://www.yiiframework.com/extensions/">Yii Extensions »</a></p>
|
<p><a class="btn btn-default" href="http://www.yiiframework.com/extensions/">Yii Extensions »</a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -11,37 +11,37 @@ $this->title = 'Login';
|
|||||||
$this->params['breadcrumbs'][] = $this->title;
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
?>
|
?>
|
||||||
<div class="site-login">
|
<div class="site-login">
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
<p>Please fill out the following fields to login:</p>
|
<p>Please fill out the following fields to login:</p>
|
||||||
|
|
||||||
<?php $form = ActiveForm::begin([
|
<?php $form = ActiveForm::begin([
|
||||||
'id' => 'login-form',
|
'id' => 'login-form',
|
||||||
'options' => ['class' => 'form-horizontal'],
|
'options' => ['class' => 'form-horizontal'],
|
||||||
'fieldConfig' => [
|
'fieldConfig' => [
|
||||||
'template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
|
'template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
|
||||||
'labelOptions' => ['class' => 'col-lg-1 control-label'],
|
'labelOptions' => ['class' => 'col-lg-1 control-label'],
|
||||||
],
|
],
|
||||||
]); ?>
|
]); ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'username') ?>
|
<?= $form->field($model, 'username') ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'password')->passwordInput() ?>
|
<?= $form->field($model, 'password')->passwordInput() ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'rememberMe', [
|
<?= $form->field($model, 'rememberMe', [
|
||||||
'template' => "<div class=\"col-lg-offset-1 col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
|
'template' => "<div class=\"col-lg-offset-1 col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
|
||||||
])->checkbox() ?>
|
])->checkbox() ?>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-lg-offset-1 col-lg-11">
|
<div class="col-lg-offset-1 col-lg-11">
|
||||||
<?= Html::submitButton('Login', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?>
|
<?= Html::submitButton('Login', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php ActiveForm::end(); ?>
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
<div class="col-lg-offset-1" style="color:#999;">
|
<div class="col-lg-offset-1" style="color:#999;">
|
||||||
You may login with <strong>admin/admin</strong> or <strong>demo/demo</strong>.<br>
|
You may login with <strong>admin/admin</strong> or <strong>demo/demo</strong>.<br>
|
||||||
To modify the username/password, please check out the code <code>app\models\User::$users</code>.
|
To modify the username/password, please check out the code <code>app\models\User::$users</code>.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
// NOTE: Make sure this file is not accessible when deployed to production
|
// NOTE: Make sure this file is not accessible when deployed to production
|
||||||
if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
|
if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
|
||||||
die('You are not allowed to access this file.');
|
die('You are not allowed to access this file.');
|
||||||
}
|
}
|
||||||
|
|
||||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||||
|
Loading…
Reference in New Issue
Block a user