Basic Login Form - Routing fails


so I’m currently looking into Neos CMS and wanted to create a very basic login logic. [for practice]

I basically followed:

Here is my code:

I also defined the following route in the global Routes.yaml file:

 ## VMP.Auth Routes
   name: 'Authentication'
   uriPattern: 'authenticate'
     '@package': 'VMP.Auth'
     '@controller': 'Authentication'
     '@action': 'authenticate'

 # TYPO3 Neos subroutes
   name: 'TYPO3 Neos'
   uriPattern: '<TYPO3NeosSubroutes>'
       package: 'TYPO3.Neos'
         'defaultUriSuffix': '.html'`

I experience the following behavior:

If I go to www. neos. dev/authenticate I get:
Validation failed while trying to call VMP\Auth\Controller\AuthenticationController->authenticateAction().

SO I think the route is working - but it still might be working inproperly, since when I actually submit the login form with some proper credentials [ action=“authenticate” ] I get:

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.

Since I’m new to Neos/Flow, I have no Idea what’s wrong here. I also can’t find any Exception Logs.

Note: I took out the @ in the route because this board thought I was refereing to users

And how can I get rid of the route? Somehow, ForntEndLogin Plugin which is shipped with neos does not use ane routes, but I cant see why.

If you use preformated text (prefixed with 4 space caracters) you can use the @ sign without problem.

PS: I edit your post to fix the styling issue

Hi overflow,

As you can see in the section Request Pattern of ´the security docs the authentication switches between the pattern to match one provider to authenticate.

In the FrontendLogin Plugin is a new authentication provider defined in the Settings.yaml:

              'Flowpack\Neos\FrontendLogin\Security\NeosRequestPattern': 'backend'
            provider: 'PersistedUsernamePasswordProvider'
              'Flowpack\Neos\FrontendLogin\Security\NeosRequestPattern': 'frontend'`

On the demo page you can add a new user by the following command on the terminal:

./flow user:create --authentication-provider "Flowpack.Neos.FrontendLogin:Frontend" --roles "Flowpack.Neos.FrontendLogin:User"

With this command you add a new User with the authentication provider “Flowpack.Neos.FrontendLogin:Frontend”.

If a user tries to login in a form the authentication will try step by step the defined provider until one works.

i hope i understand the authentication enough to not tell you no shit :joy:

I think for a simple login form you don´´´´´´’t need to have a separate route for the authentication.
The form should only point to your own authentication Controller (Fluid Form).

Hopefully I could help you a little.

I’m not really using <f:form> like FrontendLogin Plugin, so thats probably why I need routing. The docs say that I need routing. I want to make it work with routing. Using f:form will be the next step, so sry, thsi doesn’t help me. but thanks

If you want to create a basic login form that is maybe inside the main template of the site without the use of a plugin, you can add a simple form like this:

<f:form package="Your.Package" actionUri="authenticate"  method="post" class="form">
    <input type="text" id="username" name="__authentication[TYPO3][Flow][Security][Authentication][Token][UsernamePassword][username]" required />
    <input type="password" id="password" name="__authentication[TYPO3][Flow][Security][Authentication][Token][UsernamePassword][password]" required />

After that, you can define routes in the Routes.yaml of your site package (Like the routes of the TYPO3.Neos Package):

  name: 'Login form'
  uriPattern: 'login(.{@format})'
    '@action': 'index'
    '@controller': 'Authentication'
    '@format': 'html'
  httpMethods: ['GET']

  name: 'Authenticate'
  uriPattern: 'authenticate(.{@format})'
    '@action': 'authenticate'
    '@controller': 'Authentication'
    '@format': 'html'
  httpMethods: ['POST']
  appendExceedingArguments: TRUE

  name:  'Logout'
  uriPattern: 'logout(.{@format})'
    '@action': 'logout'
    '@controller': 'Authentication'
    '@format': 'html'
  httpMethods: ['POST']

In the main Routes.yaml of your Project your can add the following:

## VMP.Auth subroutes
  name: 'VMP.Auth'
  uriPattern: '<VMPSubroutes>'
      package: 'VMP.Auth'
      suffix:  'vmp'

This route should be used before the Neos subroutes.
This loads all defined routes of your VMP.Auth package.

Now you should be able to open http://your-dev.domain/vmp/login.html and see the index action of your ‘AuthenticationController’.

I hope this helps.

I 'll go through it and see if it works. But it looks promising.

Thanks :slight_smile: