所以我目前正在研究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.
我真的不知道有什麼問題在這裏。我想我的路由是錯誤的,但我看不到它。