Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Full-Stack Vue.js 2 and Laravel 5

You're reading from   Full-Stack Vue.js 2 and Laravel 5 Bring the frontend and backend together with Vue, Vuex, and Laravel

Arrow left icon
Product type Paperback
Published in Dec 2017
Publisher Packt
ISBN-13 9781788299589
Length 376 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Anthony Gore Anthony Gore
Author Profile Icon Anthony Gore
Anthony Gore
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Hello Vue – An Introduction to Vue.js FREE CHAPTER 2. Prototyping Vuebnb, Your First Vue.js Project 3. Setting Up a Laravel Development Environment 4. Building a Web Service with Laravel 5. Integrating Laravel and Vue.js with Webpack 6. Composing Widgets with Vue.js Components 7. Building a Multi-Page App with Vue Router 8. Managing Your Application State with Vuex 9. Adding a User Login and API Authentication with Passport 10. Deploying a Full-Stack App to the Cloud

Login system


Now that we have our user model created, we can implement the rest of the login system. Again, Laravel includes this as an out-of-the-box feature, so there is only a small amount of configuration for us to do.

Here's an overview of how the login system works:

  1. The user provides their email and password in a login form. We'll create this form with Vue
  2. The form is submitted to the /login POST route
  3. The LoginController will then verify the user's credentials against the database

 

  1. If the login is successful, the user is redirected to the home page. A session cookie is attached to the response, which is then passed to all outgoing requests to verify the user

Here's a diagrammatic representation of the login system for further clarity:

Figure 9.1. Login flow

LoginPage component

We will need a login page for our app, so let's create a new page component:

$ touch resources/assets/components/LoginPage.vue

We'll begin by defining the template markup, which includes a form with fields for email and...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime