Laravel Authenticate user from different website

I have 2 different website. Public facing site is developed in WordPress and project functionality is developed in Laravel.

I have placed login form in WordPress, and trying to do login from wordpress custom form to Laravel project module. but there are issues related to csrf token mismatch.

Read More

Here is the code from wordpress site:

<form role="login" action="http://projectmodule.com/auth/login">
  <input type="text" name="username" />
  <input type="password" name="password" />
  <input type="submit" name="login" value="Login" />
</form>

Is there any way I can authenticate the user from wordpress to Laravel without using any Laravel packages. OR how to stop csrf token validation only for specific route?

I’m using Laravel 5.0 and WordPress 4.4 version.

Related posts

3 comments

  1. If you are using Laravel 5.1 you can exclude specific routes from the CSRF Middleware. Check the file appHttpMiddlewareVerifyCsrfToken.php

    class VerifyCsrfToken extends BaseVerifier
    {
        /**
         * The URIs that should be excluded from CSRF verification.
         *
         * @var array
         */
        protected $except = [
            'your_route_here'
        ];
    }
    

    for all the routes specified in the $except array, the middleware will not be executed

Comments are closed.