Firebase Auth Tutorial #6 - Signing Users Out
Key Takeaways
Signs users out of a Firebase application using Vue and Firebase Auth
Full Transcript
or rather my friends so at the minute now we have all of our signup form code written so we can sign new users up I'll be it this is not very fun at the minute all we're doing is logging out this credential not really doing anything for the user so there's no point in signing up but all that functionality is gonna come in time and promise you anyway now when we've signed up a new user when we use this method like you said automatically firebase logs us into the application so in their eyes now we're logged in and we get this auth token back okay so that says that we're logged in now then how do we log a user out of the application well it's actually pretty simple we just use a different method so like we use this method over here to sign someone up we just use a different method to log someone out now we have up in the navigation over here this logout oops not that one this logout link so what we need to do is get a reference to that attached a click event to that link and then when a user clicks on it we want to prevent the default action if there isn't it then we want to sign them out using the Sign Out method so then let's do that so if we go to the index and we go to the nav bar at the top we can see this thing right here where is it will log out there so this has an ID of logout so we're going to use that to grab a reference to this anchor tag right here so in auth is let's just neaten this up a little bit I'm gonna delete that console dot log we don't need that anymore but down below what I'm going to do is now a logout method so underneath this will say Const logout is going to be equal to documents doctor query selector and we're going to grab that logout and ID which is the link in the nav bar so log out okay so we have that reference we want to add an event listener to that so log out which is the constant we just created dots add event listener and this event listener it's just going to be a click event so when someone clicks that link at the top and then we're going to find a callback function we'll take in the event object by default and we'll use that inside the error function so that we can prevent the default action and we'll do that by saying e documents default like so invoke that function okay so the next thing we want to do is use a sign out method now again we use the auth object that we declared down here we set up a reference to the auth service and we use all the off methods now on this earth constant so then the way we do this is by grabbing the earth constant then using a method called sign out like so that's all there is to it we don't need to pass in a username or password or an email the user is already logged in and firebase knows this user is logged in so it's gonna take that current user and it's gonna log them out now again this is an asynchronous task it has to communicate with the firebase back-end go out and say look I want to love this user out and then it returns some kind of response to us so because this takes some time to do it returns a promise we can tack on the dot then method and inside here we can fire a callback function this is going to be an error function we don't need to take a response from the server this time all I want to do is just log a little message to the console to say look this user has now logged out later on what we'll be doing is when they log out we're going to be hiding content from them but right now I just want to get the basics of this kind of login or logout authentication flow going so so now we'll just log through the console a little message that says that the user has signed out so console dot log user signed out okay that's all there is to it so then let us now save this and test this out in the browser so we're currently logged in even though we don't see that token right here we're logged in because we recently signed up in the last video and when we signed up it automatically logs us in okay so we're still logged in because of state persistence which means that whenever we refresh the page firebase persists the state of the user was still logged in and now if I log out then we can see this user signed out and that was very quick right so when to the server Sanders out came back and then we logged this message right here user signed out okay so although there's no change to the front ending what we see and what we do and there's no real use to this logging in and logging out at the minute at least we've got the basic flow sorted so that when we click sign we can sign up and when we click log out we're signing the new user out of the application so now we've got those two sorted let us look in the next video and logging in a current user so the court news it is Marriott at the NIT means you don't code at UK we did that in the last video when we signed users up so now we've logged out let's look at how we love that user back in in the very next tutorial
Original Description
Hey gang, in this Firebase auth video we'll see how we can sign users out of our application.
VUE & FIREBASE FULL COURSE - https://www.udemy.com/build-web-apps-with-vuejs-firebase/?couponCode=NINJAYT18
----------------------------------------
🐱💻 🐱💻 Course Links:
+ Course files - https://github.com/iamshaunjp/firebase-auth
+ VS Code editor - https://code.visualstudio.com/
+ Firestore Playlist -
+ Materialize Playlist -
🤑🤑 Donate
+ https://www.paypal.me/thenetninja
🎓🎓 Find me on Udemy
+ https://www.udemy.com/user/47fd83f6-5e4a-4e87-a0f0-519ac51f91b6/
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Net Ninja · Net Ninja · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
GraphQL Tutorial #5 - Express App Setup
Net Ninja
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
GraphQL Tutorial #8 - Root Query
Net Ninja
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
GraphQL Tutorial #12 - Author Type
Net Ninja
GraphQL Tutorial #13 - Type Relations
Net Ninja
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
GraphQL Tutorial #18 - Mutations
Net Ninja
GraphQL Tutorial #19 - More on Mutations
Net Ninja
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
GraphQL Tutorial #23 - Create React App
Net Ninja
GraphQL Tutorial #24 - Book List Component
Net Ninja
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
GraphQL Tutorial #28 - Add Book Component
Net Ninja
GraphQL Tutorial #29 - External Query File
Net Ninja
GraphQL Tutorial #30 - Updating Component State
Net Ninja
GraphQL Tutorial #31 - Composing Queries
Net Ninja
GraphQL Tutorial #32 - query variables
Net Ninja
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
GraphQL Tutorial #34 - Book Details Component
Net Ninja
GraphQL Tutorial #36 - Styling the App
Net Ninja
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
Updated Vue & Firebase Course (Udemy)
Net Ninja
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja
More on: Backend Performance
View skill →
🎓
Tutor Explanation
DeepCamp AI