无法解析路由 - 基本登录
所以我目前正在研究Neos CMS并希望创建一个非常基本的登录逻辑。 [实践]无法解析路由 - 基本登录
我的代码:[近地天体的/是根目录]
路线: [近地天体/配置/ Routes.yaml注意这是我加什么在文件的开头,不是文件的全部内容。
-
name: 'Authentication'
uriPattern: 'authenticate'
defaults:
'@package': 'VMP.Auth'
'@controller': 'Authentication'
'@action': 'authenticate'
AuthenticationController.php [近地物体/封装/插件/ VMP.Auth /类别/ VMP /验证/控制器/]
<?php
namespace VMP\Auth\Controller;
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Mvc\ActionRequest;
use TYPO3\Flow\Security\Authentication\Controller\AbstractAuthenticationController;
class AuthenticationController extends AbstractAuthenticationController {
/**
* Displays a login form
*
* @return void
*/
public function indexAction() {
}
/**
* Will be triggered upon successful authentication
*
* @param ActionRequest $originalRequest The request that was intercepted by the security framework, NULL if there was none
* @return string
*/
protected function onAuthenticationSuccess(ActionRequest $originalRequest = NULL) {
if ($originalRequest !== NULL) {
$this->redirectToRequest($originalRequest);
}
$this->redirect('someDefaultActionAfterLogin');
}
/**
* Logs all active tokens out and redirects the user to the login form
*
* @return void
*/
public function logoutAction() {
parent::logoutAction();
$this->addFlashMessage('Logout successful');
$this->redirect('index');
}
public function fooAction() {
print "lol";
}
}
NodeTypes.yaml [近地物体/封装/插件/VMP.Auth/Configuration/]
'VMP.Auth:Plugin':
superTypes:
'TYPO3.Neos:Plugin': TRUE
ui:
label: 'Auth Login Form'
group: 'plugins'
Policy.yaml [新S /包/插件/ VMP.Auth /配置/]
privilegeTargets:
'TYPO3\Flow\Security\Authorization\Privilege\Method\MethodPrivilege':
'VMP.Auth:Plugin':
matcher: 'method(TYPO3\Flow\Security\Authentication\Controller\AbstractAuthenticationController->(?!initialize).*Action()) || method(VMP\Auth\Controller\AuthenticationController->(?!initialize).*Action())'
roles:
'TYPO3.Flow:Everybody':
privileges:
-
# Grant any user access to the FrontendLoginLoginForm plugin
privilegeTarget: 'VMP.Auth:Plugin'
permission: GRANT
Settings.yaml [近地物体/封装/插件/ VMP.Auth /配置/]
TYPO3:
Neos:
typoScript:
autoInclude:
'VMP.Auth': TRUE
Flow:
security:
authentication:
providers:
'AuthAuthenticationProvider':
provider: 'PersistedUsernamePasswordProvider'
的index.html [近地天体/封装/插件/ VMP.Auth /资源/个人/模板/认证/]
<form action="authenticate" method="post">
<input type="text"
name="__authentication[TYPO3][Flow][Security][Authentication][Token][UsernamePassword][username]" />
<input type="password" name="__authentication[TYPO3][Flow][Security][Authentication][Token][UsernamePassword][password]" />
<input type="submit" value="Login" />
</form>
** Root.ts2 [近地天体/封装/插件/ VM P.Auth /资源/ Typo脚本/]
prototype(VMP.Auth:Plugin) < prototype(TYPO3.Neos:Plugin)
prototype(VMP.Auth:Plugin) {
package = 'VMP.Auth'
controller = 'Authentication'
action = 'index'
}
问题: 如果我叫:www.neos.dev/authenticate我得到:
Validation failed while trying to call VMP\Auth\Controller\AuthenticationController->authenticateAction().
所以我认为,路线本身并工作。我现在将VMP.Auth插件的登录表单添加到某个页面并登录(与现有用户一起使用)。登录表单应用/认证作为其行动,但现在我得到以下错误:
Page Not Found
Sorry, the page you requested was not found.
#1301610453: Could not resolve a route and its corresponding URI for the given parameters. This may be due to referring to a not existing package/controller/action while building a link or URI. Refer to log and check the backtrace for more details.
我真的不知道有什么问题在这里。我想我的路由是错误的,但我看不到它。
您onAuthenticationSuccess
方法有:
$this->redirect('someDefaultActionAfterLogin');
这可能是触发(正确地)了。这会尝试重定向到您的AuthenticationController
中的动作someDefaultActionAfterLoginAction
,但此操作不存在。对于初学者,尝试 $this->redirectToUri('/')
只需重定向到主页。