Laravel: Page login form without Laravel

I am creating a web application that is accompanied by a small website that uses Jekyll. The reason for this is that the website will almost never change and thus it will be able to work quickly (pure HTML + CSS and some JavaScript) and is semi-application independent.

The Jekyll site is placed in the Laravel public folder and works great. As a user, a user who wants to use our application should visit the standard Laravel route for logging in (/ login).

I would like to add a login form to one of my site pages, which allows the user to log in without visiting the application in the first place.

Of course, I tried adding a simple form and submitting it to / login (the default Laravel route), but this will not work because Laravel expects the csrf token to be installed. I know that Laravel sets a cookie containing an encrypted token, but I'm not sure what (and how) I can use it.

Is there a (simple) way to add a login form to a NON-Laravel page? And can this be done using only HTML and JavaScript (possibly using Ajax)?

+4
source share
1 answer

You have several options.

1- : csrf_token . , , . , .

2- GET ajax , csrf_token, . Laravel

public function getToken() {
    return session()->token();
}

3 - API , SPA. https://laravel.com/docs/5.4/passport

+3

Source: https://habr.com/ru/post/1676025/


All Articles