tol64

tol64

Member Since 11 Months Ago

Experience Points
1,520
Total
Experience

3,480 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
10
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
1,520 XP
Jul
29
1 month ago
Activity icon

Replied to Laravel Echo: ListenForWhisper Not Working

Perhaps it's enough to add this code.

routes\channels.php

Broadcast::channel('chat', function ($user) {
    return Auth::check();
});
Jul
02
2 months ago
Activity icon

Awarded Best Reply on Laragon/Nginx + Laravel + Nuxt: 419 — CSRF Token Mismatch

Hi.

I installed the latest version of nuxtjs/auth, which is now under development: nuxtjs/auth-next

And applied the strategy with JWT: https://dev.auth.nuxtjs.org/providers/laravel-jwt.html#usage

And it worked!

Activity icon

Replied to Laragon/Nginx + Laravel + Nuxt: 419 — CSRF Token Mismatch

Hi.

I installed the latest version of nuxtjs/auth, which is now under development: nuxtjs/auth-next

And applied the strategy with JWT: https://dev.auth.nuxtjs.org/providers/laravel-jwt.html#usage

And it worked!

Jun
30
2 months ago
Activity icon

Started a new Conversation [Vue Warn]: Cannot Set Reactive Property On Undefined, Null, Or Primitive Value: Undefined

Go to the Vuex tab in the Vue devtools browser extension.

001.png

We see this result and the console displays errors.

002.gif

003.png

How do you get rid of these mistakes?

Jun
29
2 months ago
Activity icon

Started a new Conversation Laravel And Nuxt: Authenticating

Hello, everybody!

Trying to authenticate with Laravel Sanctum and NuxtJS (auth module).

Laravel help shows how to initiate CSRF protection: https://laravel.com/docs/7.x/sanctum#spa-authenticating.

axios.get('/sanctum/csrf-cookie').then(response => {
    // Login...
});

And you can see this result in the list of requests (Response headers):

HTTP/1.1 204 No Content
Host: localhost:8000
Date: Mon, 29 Jun 2020 09:48:17 GMT
Connection: close
X-Powered-By: PHP/7.4.6
Cache-Control: no-cache, private
Date: Mon, 29 Jun 2020 09:48:17 GMT
Access-Control-Allow-Origin: http://localhost:3000
Vary: Origin
Access-Control-Allow-Credentials: true
Set-Cookie: XSRF-TOKEN=eyJpdiI6InEvTTNjM0V3cEw3elk0aHlnVkRsVFE9PSIsInZhbHVlIjoiRjJIMmtXOXd1UXdsQVgyMFRKeEdZS2c4VG9JVU9OVXUyZUVaSjFNbTVWWG5yMFVjNHNxN2kyK3Z4NmJsQkRyQyIsIm1hYyI6ImVhMzJiMmY0MTU4YmZlMzUwNGZjOTNjODVlM2RjYWViMTAyNzBjZjk2NDhhODdkY2VkYjUyOGZiNGI0YjBkOTcifQ%3D%3D; expires=Mon, 29-Jun-2020 11:48:17 GMT; Max-Age=7200; path=/; domain=localhost; samesite=lax
Set-Cookie: laravel_session=eyJpdiI6Ii8xcW9XcXhVUjdPemxqZ0dmblRxZ3c9PSIsInZhbHVlIjoidlJJb2Nkbm1lSUF5a0pIcWxSWXdKYmVFTkpTUlF6TzZFRmVEd2RYWEsvT2syalVBV3dZSFFjS1g3SjNyK0hDNSIsIm1hYyI6ImFjMGU2YjgwZmIwMWU2YWY5MmU5ZDcyZTBjNWI0NTVhMzk4YTE5NGY4MjY5ZjBhNDVhZTBmODgxMjI3ZGQ5MTQifQ%3D%3D; expires=Mon, 29-Jun-2020 11:48:17 GMT; Max-Age=7200; path=/; domain=localhost; httponly; samesite=lax

Then we get an error (419 - CSRF token mismatch.) when trying to login:

                await this.$auth.loginWith('local', {
                    email: this.form.email,
                    password: this.form.password,
                });

What does it take to make it work?

Jun
26
3 months ago
Activity icon

Replied to Laragon/Nginx + Laravel + Nuxt: 419 — CSRF Token Mismatch

Guys, is this question too complicated? Can you please tell me in which direction to go next?

Activity icon

Started a new Conversation Laragon/Nginx + Laravel + Nuxt: 419 — CSRF Token Mismatch

I'm asking you to help me figure it out and solve the problem.

A series of lessons based on the material: https://youtu.be/KFgi3IqavK4

Windows 10 operating system

Path to the project: C:\laragon\www\larastart-project

There are two folders in this directory:

  • C:\laragon\www\larastart-project\backend
  • C:\laragon\www\larastart-project\frontend

The first (backend) is the Laravel framework.

The second (frontend) is the Nuxt framework.

Laragon/Nginx settings

Laragon

Contents of the file auto.larastart-project.test.conf

server {
    listen 8080;
    listen 8443 ssl;
    server_name larastart-project.test *.larastart-project.test;
    root "C:/laragon/www/larastart-project/";
    
    index index.html index.htm index.php;
 
    location / {
    proxy_buffers 16 4k;
    proxy_buffer_size 2k;
    
    # npm run dev
    proxy_pass http://localhost:3000;
    
    # try_files $uri $uri/ /index.php$is_args$args;
    # autoindex on;
    }
  
    location /api {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    
    # php artisan serve
    proxy_pass http://localhost:8000/api;
    }
    
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass php_upstream;		
        #fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    # Enable SSL
    ssl_certificate "C:/laragon/etc/ssl/laragon.crt";
    ssl_certificate_key "C:/laragon/etc/ssl/laragon.key";
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
    ssl_prefer_server_ciphers on;
  
  
    charset utf-8;
  
    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }
    location ~ /\.ht {
        deny all;
    }
}

Laravel settings

Dependencies in composer.json. The package Sanctum is used for authentication: https://laravel.com/docs/7.x/sanctum#spa-authentication

"require": {
        "php": "^7.2.5",
        "fideloper/proxy": "^4.2",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^6.3",
        "intervention/image": "^2.5",
        "laravel/framework": "^7.0",
        "laravel/sanctum": "^2.4",
        "laravel/tinker": "^2.0",
        "spatie/laravel-medialibrary": "8.0.0"
    },
    "require-dev": {
        "barryvdh/laravel-ide-helper": "^2.7",
        "facade/ignition": "^2.0",
        "fzaninotto/faker": "^1.9.1",
        "laravel/ui": "^2.0",
        "mockery/mockery": "^1.3.1",
        "nunomaduro/collision": "^4.1",
        "phpunit/phpunit": "^8.5"
    },

File .env

APP_URL=http://localhost
CORS_ALLOWED_ORIGIN=http://localhost:3000
SANCTUM_STATEFUL_DOMAINS=http://localhost:8000
SESSION_DRIVER=file
SESSION_DOMAIN=localhost

File config\cors.php

return [
    'paths' => [
        'api/*',
        'login',
        'logout',
        'user',
        'sanctum/csrf-cookie',
    ],
    'allowed_methods' => ['*'],
    'allowed_origins' => ['*'],
    'allowed_origins_patterns' => [],
    'allowed_headers' => ['*'],
    'exposed_headers' => [],
    'max_age' => 0,
    'supports_credentials' => true,
];

File app\Http\Kernel.php

...
protected $middlewareGroups = [
...
        'api' => [
            EnsureFrontendRequestsAreStateful::class,
            'throttle:60,1',
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],
    ];
...

Nuxt settings

Dependencies in package.json

    "dependencies": {
        "@nuxtjs/auth": "^4.9.1",
        "@nuxtjs/axios": "^5.3.6",
        "@nuxtjs/dotenv": "^1.4.1",
        "@nuxtjs/proxy": "^2.0.0",
        "bootstrap": "^4.5.0",
        "bootstrap-vue": "^2.15.0",
        "cookie-universal-nuxt": "^2.1.4",
        "iview": "^3.1.5",
        "jquery": "^3.5.1",
        "moment": "^2.27.0",
        "nuxt": "^2.0.0",
        "popper.js": "^1.16.1",
        "prismjs": "^1.20.0"
    },
    "devDependencies": {
        "node-sass": "^4.14.1",
        "nuxt-purgecss": "^1.0.0",
        "sass-loader": "^8.0.2"
    }

File .env

API_URL=http://localhost:8000/api
API_DOMAIN=http://localhost:8000

File nuxt.config.js

The settings related to authentication are shown.

...
    modules: [
        '@nuxtjs/axios',
        '@nuxtjs/auth',
        '@nuxtjs/proxy',
        '@nuxtjs/dotenv',
        'bootstrap-vue/nuxt',
        [
            'cookie-universal-nuxt', {
                alias: 'cookie'
            }
        ],
    ],
    auth: {
        strategies: {
            local: {
                endpoints: {
                    login: {
                        url: process.env.API_DOMAIN + '/login',
                        method: 'post'
                    },
                    logout: {
                        url: process.env.API_DOMAIN + '/logout',
                        method: 'post'
                    },
                    user: {
                        url: process.env.API_DOMAIN + '/user',
                        method: 'get',
                        propertyName: false
                    }
                },
                tokenRequired: false,
                tokenType: false
            }
        }
    },
    axios: {
        baseURL: process.env.API_DOMAIN,
        credentials: true
    },
...

Check the token request in the program Postman: https://www.postman.com/.

You can see that the data is being released.

Postman

Then we make a page with a test form: pages\auth\signin.vue

Method code:

   methods: {
        async login() {
            try {
                await this.$axios.$get('http://localhost:8000/sanctum/csrf-cookie');
                await this.$auth.loginWith('local', {
                    email: this.form.email,
                    password: this.form.password,
                });
                this.$router.replace('/');
            } 
            catch (e) {
                this.errors = 'Could not sign you with these credentials.';
                console.log(e);
            }
        }
    }

Result:

Result

More:

More_01

More_02

More_03

There is no XSRF-TOKEN on the Application tab. It seems to be here also when sending the form data.

More_04

Try to play it at your place. Can you tell me what's missing, please?