Laravel sanctum and Vue-JS SPA: Unterschied zwischen den Versionen
Aus Froggis Wissenssammlung
Froggi (Diskussion | Beiträge) K (Froggi verschob die Seite Laravel sanctum and Vue-JS nach Laravel sanctum and Vue-JS SPA, ohne dabei eine Weiterleitung anzulegen) |
Froggi (Diskussion | Beiträge) |
||
| Zeile 1: | Zeile 1: | ||
| − | === 1. Install laravel sanctum === | + | ===1. Install laravel sanctum=== |
You may install Laravel Sanctum via Composer: | You may install Laravel Sanctum via Composer: | ||
<code>composer require laravel/sanctum</code> | <code>composer require laravel/sanctum</code> | ||
| − | + | Now follow the instructions from https://laravel.com/docs/7.x/sanctum#installation to complete the installation. Especially look at the configuration. | |
| − | + | ||
| − | + | === 2. Use it to authenticate a user === | |
| − | + | As described in the official docs do: | |
| − | + | ||
| − | + | ||
| − | + | <code>axios.get('/sanctum/csrf-cookie').then(response => { | |
| − | + | // Login... | |
| − | + | });</code> | |
| − | + | ||
| − | + | The loginn can be the standard login of Laravels scaffolding or a custom one. | |
| − | |||
| − | |||
Version vom 13. August 2020, 13:35 Uhr
1. Install laravel sanctum
You may install Laravel Sanctum via Composer:
composer require laravel/sanctum
Now follow the instructions from https://laravel.com/docs/7.x/sanctum#installation to complete the installation. Especially look at the configuration.
2. Use it to authenticate a user
As described in the official docs do:
axios.get('/sanctum/csrf-cookie').then(response => {
// Login...
});
The loginn can be the standard login of Laravels scaffolding or a custom one.