Building Real-World Web Applications with Vue.js 3 by Joran Quinten
Author:Joran Quinten
Language: eng
Format: epub
Publisher: Packt Publishing Pvt. Ltd.
Published: 2023-12-15T00:00:00+00:00
User store
We will want to have access and the ability to update the status of the user at all times, so weâll set up a user store in Pinia that will keep track of the current state and provide actions on updating the state and logging in and out.
Weâll go over the contents of the store, after creating a user.ts file in the src/store folder with the following contents: https://github.com/PacktPublishing/Building-Real-world-Web-Applications-with-Vue.js-3/blob/main/06.fitness/.notes/6.1-user.ts.
In the session (line 11), weâll store the authentication state of the user. It can either be null for not logged in or the state can hold an object (as defined in the UserSession interface), which gets populated by the Supabase authorization service.
With the login (lines 13-20) and logout (lines 22-30) methods, we are calling the Supabase authentication services and executing a provided callback function. We will see these in action shortly!
To store the user, we have the insertProfile function (lines 32-44), which upserts any authenticated user to our database for future reference.
Note
Storing personal data may be subject to local law and governance. Be very diligent and transparent in what you store, why youâre storing it, and how you remove personal data.
setUserSession (lines 47-49) simply passes the data to the state for further reference. Lastly, userIsLoggedIn (lines 51-58) checks whether the current session data is still valid, and if not, it returns false. We can use this for quick assessments on displaying user interface elements.
Having the store in place, we can incorporate profiles in our app with some sensible safety measures.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Hello! Python by Anthony Briggs(9388)
The Mikado Method by Ola Ellnestam Daniel Brolund(9321)
Dependency Injection in .NET by Mark Seemann(8867)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7411)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7127)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(6256)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(5969)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5518)
Kotlin in Action by Dmitry Jemerov(4654)
Audition by Ryu Murakami(4107)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(3917)
Functional Programming in JavaScript by Mantyla Dan(3727)
Svelte with Test-Driven Development by Daniel Irvine(3061)
Learning React: Functional Web Development with React and Redux by Banks Alex & Porcello Eve(2847)
Layered Design for Ruby on Rails Applications by Dementyev Vladimir;(2686)
Test-Driven Development with PHP 8 by Rainier Sarabia(2661)
WordPress Plugin Development Cookbook by Yannick Lefebvre(2628)
Architecting Modern Java EE Applications: Designing lightweight, business-oriented enterprise applications in the age of cloud, containers, and Java EE 8 by Daschner Sebastian(2565)
React Native - Building Mobile Apps with JavaScript by Novick Vladimir(2344)