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.
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.
If you are using Laravel 5.1 you can exclude specific routes from the CSRF Middleware. Check the file
appHttpMiddlewareVerifyCsrfToken.php
for all the routes specified in the
$except
array, the middleware will not be executedYour question is related to CORS(Cross site resource sharing).
Here is the good link to implement and understand step by step provided by Tino Tkalec.
http://www.toptal.com/web/cookie-free-authentication-with-json-web-tokens-an-example-in-laravel-and-angularjs
and its github repo is https://github.com/ttkalec/laravel5-angular-jwt
You will learn and implement easily by this way.
Here are the couple of links that skips CSRF verification for specified routes in Laravel 5.0 version, very simple though!
http://laravel.io/forum/11-14-2014-disabling-the-csrf-middleware-in-laravel-5
http://www.techigniter.in/tutorials/disable-csrf-check-on-specific-routes-in-laravel-5/