Мне стыдно задавать этот вопрос, но всё же.
У меня слетела верстка в функции восстановления пароля я все страницы исправил кроме одной,
я не пойму где в декстриме найти эту вьюжку,- не однократно перерыл всю директорию vendor.её нигде нет.
http://joxi.ru/gmv8ZGlFq8aXBA
через браузер отзывается так:
http://localhost/user/forgot
Но файла forgot.php
Нет
вот сайт контролер
Код: Выделить всё
<?php
namespace app\controllers;
use app\models\Article;
use app\models\Category;
use app\models\CommentForm;
use Yii;
use yii\data\Paginations;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\filters\VerbFilter;
use app\models\ContactForm;
use yii\web\NotFoundHttpException;
use yii\db\Query;
class SiteController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['logout'],
'rules' => [
[
'actions' => ['logout'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}
/**
* {@inheritdoc}
*/
/* для модера
public function behaviors() {
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['login', 'error'],
'allow' => true,
],
[
'actions' => ['logout', 'index'],
'allow' => true,
'roles' => ['@'],
],
[
'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',
'minLength' => 6,
'maxLength' => 6,
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
],
];
}
/**
* Displays homepage.
*
* @return string
*/
public function actionIndex()
{
$data = Article::getAll(1);
$popular = Article::getPopular();
$recent = Article::getRecent();
$categories = Category::getAll();
return $this->render('index',[
'articles'=>$data['articles'],
'pagination'=>$data['pagination'],
'popular'=>$popular,
'recent'=>$recent,
'categories'=>$categories
]);
}
public function actionView($id)
{
if (!$article = Article::findOne($id)) {
throw new NotFoundHttpException('Article not found');
}
$article = Article::findOne($id);
$popular = Article::getPopular();
$recent = Article::getRecent();
$categories = Category::getAll();
$comments = $article->getArticleComments();
$commentForm = new CommentForm();
$article->viewedCounter();
return $this->render('single', [
'article' => $article,
'popular' => $popular,
'recent' => $recent,
'categories' => $categories,
'comments' => $comments,
'commentForm' => $commentForm
]);
}
public function actionComment($id)
{
$model = new CommentForm();
if(Yii::$app->request->isPost)
{
$model->load(Yii::$app->request->post());
if($model->saveComment($id))
{
Yii::$app->getSession()->setFlash('comment', 'Your comment will be added soon!');
return $this->redirect(['site/view','id'=>$id]);
}
}
}
public function actionCategory($id)
{
$data = Category::getArticlesByCategory($id);
$popular = Article::getPopular();
$recent = Article::getRecent();
$categories = Category::getAll();
return $this->render('category',[
'articles'=>$data['articles'],
'pagination'=>$data['pagination'],
'popular'=>$popular,
'recent'=>$recent,
'categories'=>$categories
]);
}
public function actionCache()
{
$cache = Yii::$app->cache;
$data = $cache->get('my');
$data = $cache->get('my2');
if($data) {echo $data;}
$cache->set('my', 'Данные для кэширования', 10);
$cache->set('my2', 'Данные для кэширования', 10);
$data = $cache->get('my');
if($data) {echo $data;}
//$cache->flush();
}
}
dekstriun security.controller.php
Код: Выделить всё
<?php
/*
* This file is part of the Dektrium project.
*
* (c) Dektrium project <http://github.com/dektrium/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace dektrium\user\controllers;
use dektrium\user\Finder;
use dektrium\user\models\Account;
use dektrium\user\models\LoginForm;
use dektrium\user\models\User;
use dektrium\user\Module;
use dektrium\user\traits\AjaxValidationTrait;
use dektrium\user\traits\EventTrait;
use yii\authclient\AuthAction;
use yii\authclient\ClientInterface;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\helpers\Url;
use yii\web\Controller;
use yii\web\Response;
/**
* Controller that manages user authentication process.
*
* @property Module $module
*
* @author Dmitry Erofeev <dmeroff@gmail.com>
*/
class SecurityController extends Controller
{
use AjaxValidationTrait;
use EventTrait;
/**
* Event is triggered before logging user in.
* Triggered with \dektrium\user\events\FormEvent.
*/
const EVENT_BEFORE_LOGIN = 'beforeLogin';
/**
* Event is triggered after logging user in.
* Triggered with \dektrium\user\events\FormEvent.
*/
const EVENT_AFTER_LOGIN = 'afterLogin';
/**
* Event is triggered before logging user out.
* Triggered with \dektrium\user\events\UserEvent.
*/
const EVENT_BEFORE_LOGOUT = 'beforeLogout';
/**
* Event is triggered after logging user out.
* Triggered with \dektrium\user\events\UserEvent.
*/
const EVENT_AFTER_LOGOUT = 'afterLogout';
/**
* Event is triggered before authenticating user via social network.
* Triggered with \dektrium\user\events\AuthEvent.
*/
const EVENT_BEFORE_AUTHENTICATE = 'beforeAuthenticate';
/**
* Event is triggered after authenticating user via social network.
* Triggered with \dektrium\user\events\AuthEvent.
*/
const EVENT_AFTER_AUTHENTICATE = 'afterAuthenticate';
/**
* Event is triggered before connecting social network account to user.
* Triggered with \dektrium\user\events\AuthEvent.
*/
const EVENT_BEFORE_CONNECT = 'beforeConnect';
/**
* Event is triggered before connecting social network account to user.
* Triggered with \dektrium\user\events\AuthEvent.
*/
const EVENT_AFTER_CONNECT = 'afterConnect';
/** @var Finder */
protected $finder;
/**
* @param string $id
* @param Module $module
* @param Finder $finder
* @param array $config
*/
public function __construct($id, $module, Finder $finder, $config = [])
{
$this->finder = $finder;
parent::__construct($id, $module, $config);
}
/** @inheritdoc */
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
['allow' => true, 'actions' => ['login', 'auth'], 'roles' => ['?']],
['allow' => true, 'actions' => ['login', 'auth', 'logout'], 'roles' => ['@']],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}
/** @inheritdoc */
public function actions()
{
return [
'auth' => [
'class' => AuthAction::className(),
// if user is not logged in, will try to log him in, otherwise
// will try to connect social account to user.
'successCallback' => \Yii::$app->user->isGuest
? [$this, 'authenticate']
: [$this, 'connect'],
],
];
}
/**
* Displays the login page.
*
* @return string|Response
*/
public function actionLogin()
{
if (!\Yii::$app->user->isGuest) {
$this->goHome();
}
/** @var LoginFor<?php
/**
* @copyright Copyright © Gogodigital Srls
* @company Gogodigital Srls - Wide ICT Solutions
* @website http://www.gogodigital.it
* @github https://github.com/cinghie/yii2-user-extended
* @license GNU GENERAL PUBLIC LICENSE VERSION 3
* @package yii2-user-extended
* @version 0.6.2
*/
namespace cinghie\userextended\controllers;
use Yii;
use dektrium\user\controllers\SecurityController as BaseController;
use dektrium\user\models\LoginForm;
use yii\base\ExitException;
use yii\base\InvalidConfigException;
class SecurityController extends BaseController
{
/**
* @return bool|string
*/
public function getViewPath()
{
return Yii::getAlias('@vendor/cinghie/yii2-user-extended/views/adminlte/security');
}
/**
* Displays the login page.
*
* @return string|Response
* @throws ExitException
* @throws InvalidConfigException
*/
public function actionLogin()
{
if (!Yii::$app->user->isGuest) {
$this->goHome();
}
/** @var LoginForm $model */
$model = Yii::createObject(LoginForm::className());
$event = $this->getFormEvent($model);
$this->performAjaxValidation($model);
$this->trigger(self::EVENT_BEFORE_LOGIN, $event);
Yii::$app->session->setFlash('login', Yii::t('userextended','Type your credentials'));
if($model->load(Yii::$app->getRequest()->post()))
{
if ($model->login()) {
Yii::$app->session->setFlash('login', Yii::t('userextended', 'Login successful'));
$this->trigger(self::EVENT_AFTER_LOGIN, $event);
return $this->goBack();
}
Yii::$app->session->setFlash('login', Yii::t('userextended', 'Incorrect Username or Password'));
}
$view = Yii::$app->getModule('userextended')->templateLogin;
return $this->render($view, [
'model' => $model,
'module' => $this->module,
]);
}
}
[code]m $model */
$model = \Yii::createObject(LoginForm::className());
$event = $this->getFormEvent($model);
$this->performAjaxValidation($model);
$this->trigger(self::EVENT_BEFORE_LOGIN, $event);
if ($model->load(\Yii::$app->getRequest()->post()) && $model->login()) {
$this->trigger(self::EVENT_AFTER_LOGIN, $event);
return $this->goBack();
}
return $this->render('login', [
'model' => $model,
'module' => $this->module,
]);
}
/**
* Logs the user out and then redirects to the homepage.
*
* @return Response
*/
public function actionLogout()
{
$event = $this->getUserEvent(\Yii::$app->user->identity);
$this->trigger(self::EVENT_BEFORE_LOGOUT, $event);
\Yii::$app->getUser()->logout();
$this->trigger(self::EVENT_AFTER_LOGOUT, $event);
return $this->goHome();
}
/**
* Tries to authenticate user via social network. If user has already used
* this network's account, he will be logged in. Otherwise, it will try
* to create new user account.
*
* @param ClientInterface $client
*/
public function authenticate(ClientInterface $client)
{
$account = $this->finder->findAccount()->byClient($client)->one();
if (!$this->module->enableRegistration && ($account === null || $account->user === null)) {
\Yii::$app->session->setFlash('danger', \Yii::t('user', 'Registration on this website is disabled'));
$this->action->successUrl = Url::to(['/user/security/login']);
return;
}
if ($account === null) {
/** @var Account $account */
$accountObj = \Yii::createObject(Account::className());
$account = $accountObj::create($client);
}
$event = $this->getAuthEvent($account, $client);
$this->trigger(self::EVENT_BEFORE_AUTHENTICATE, $event);
if ($account->user instanceof User) {
if ($account->user->isBlocked) {
\Yii::$app->session->setFlash('danger', \Yii::t('user', 'Your account has been blocked.'));
$this->action->successUrl = Url::to(['/user/security/login']);
} else {
$account->user->updateAttributes(['last_login_at' => time()]);
\Yii::$app->user->login($account->user, $this->module->rememberFor);
$this->action->successUrl = \Yii::$app->getUser()->getReturnUrl();
}
} else {
$this->action->successUrl = $account->getConnectUrl();
}
$this->trigger(self::EVENT_AFTER_AUTHENTICATE, $event);
}
/**
* Tries to connect social account to user.
*
* @param ClientInterface $client
*/
public function connect(ClientInterface $client)
{
/** @var Account $account */
$account = \Yii::createObject(Account::className());
$event = $this->getAuthEvent($account, $client);
$this->trigger(self::EVENT_BEFORE_CONNECT, $event);
$account->connectWithUser($client);
$this->trigger(self::EVENT_AFTER_CONNECT, $event);
$this->action->successUrl = Url::to(['/user/settings/networks']);
}
}
Код: Выделить всё
<?php
/**
* @copyright Copyright © Gogodigital Srls
* @company Gogodigital Srls - Wide ICT Solutions
* @website http://www.gogodigital.it
* @github https://github.com/cinghie/yii2-user-extended
* @license GNU GENERAL PUBLIC LICENSE VERSION 3
* @package yii2-user-extended
* @version 0.6.2
*/
namespace cinghie\userextended\controllers;
use Yii;
use dektrium\user\controllers\SecurityController as BaseController;
use dektrium\user\models\LoginForm;
use yii\base\ExitException;
use yii\base\InvalidConfigException;
class SecurityController extends BaseController
{
/**
* @return bool|string
*/
public function getViewPath()
{
return Yii::getAlias('@vendor/cinghie/yii2-user-extended/views/adminlte/security');
}
/**
* Displays the login page.
*
* @return string|Response
* @throws ExitException
* @throws InvalidConfigException
*/
public function actionLogin()
{
if (!Yii::$app->user->isGuest) {
$this->goHome();
}
/** @var LoginForm $model */
$model = Yii::createObject(LoginForm::className());
$event = $this->getFormEvent($model);
$this->performAjaxValidation($model);
$this->trigger(self::EVENT_BEFORE_LOGIN, $event);
Yii::$app->session->setFlash('login', Yii::t('userextended','Type your credentials'));
if($model->load(Yii::$app->getRequest()->post()))
{
if ($model->login()) {
Yii::$app->session->setFlash('login', Yii::t('userextended', 'Login successful'));
$this->trigger(self::EVENT_AFTER_LOGIN, $event);
return $this->goBack();
}
Yii::$app->session->setFlash('login', Yii::t('userextended', 'Incorrect Username or Password'));
}
$view = Yii::$app->getModule('userextended')->templateLogin;
return $this->render($view, [
'model' => $model,
'module' => $this->module,
]);
}
}