无法解析路由 - 基本登录



因此,我目前正在研究NEOS CMS,并希望创建一个非常基本的登录逻辑。[练习]

我基本上遵循:http://flowframework.readthedocs.io/en/stable/thedefinistiveguide/partiii/partiii/security.html#authentication

我的代码:[neos/是root dir]

路由: [neos/configuration/doutes.yaml]注意,这是我在文件开头添加的,而不是文件的全部内容。

-
  name: 'Authentication'
  uriPattern: 'authenticate'
  defaults:
    '@package': 'VMP.Auth'
    '@controller': 'Authentication'
    '@action': 'authenticate'

AuthenticationController.php [Neos/packages/plugins/vmp.auth/class/class/vmp/auth/controller/]

<?php
namespace VMPAuthController;
use TYPO3FlowAnnotations as Flow;
use TYPO3FlowMvcActionRequest;
use TYPO3FlowSecurityAuthenticationControllerAbstractAuthenticationController;
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 [neos/packages/plugins/vmp.auth/configuration/]

'VMP.Auth:Plugin':
  superTypes:
    'TYPO3.Neos:Plugin': TRUE
  ui:
    label: 'Auth Login Form'
    group: 'plugins'

polition.yaml [neos/packages/plugins/vmp.auth/configuration/]

privilegeTargets:
  'TYPO3FlowSecurityAuthorizationPrivilegeMethodMethodPrivilege':
    'VMP.Auth:Plugin':
      matcher: 'method(TYPO3FlowSecurityAuthenticationControllerAbstractAuthenticationController->(?!initialize).*Action()) || method(VMPAuthControllerAuthenticationController->(?!initialize).*Action())'
roles:
  'TYPO3.Flow:Everybody':
    privileges:
      -
          # Grant any user access to the FrontendLoginLoginForm plugin
        privilegeTarget: 'VMP.Auth:Plugin'
        permission: GRANT

settings.yaml [neos/packages/plugins/vmp.auth/configuration/]

TYPO3:
  Neos:
    typoScript:
      autoInclude:
        'VMP.Auth': TRUE
  Flow:
    security:
      authentication:
        providers:
          'AuthAuthenticationProvider':
            provider: 'PersistedUsernamePasswordProvider'

index.html [neos/packages/plugins/vmp.auth/resources/private/private/templates/authentication/]

<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 [neos/packages/plugins/vmp.auth/resources/typoscript/]

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 VMPAuthControllerAuthenticationController->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('/')只需重定向到主页。

最新更新