In this lesson, we will show the user's name and email and will build the Log out button.

Composable Method
First, in the auth Composable, let's add a reactive user object.
resources/composables/auth.js:
import { ref, reactive } from 'vue'import { useRouter } from "vue-router"; const user = reactive({ name: '', email: '',}) // ...
Then, after successful login, we need to assign the values to that object.
resources/composables/auth.js:
import { ref, reactive, inject } from 'vue'import { useRouter } from 'vue-router'; const user = reactive({ name: '', email: '',}) export default function useAuth() { // ... const loginUser = (response) => { user.name = response.data.name user.email = response.data.email localStorage.setItem('loggedIn', JSON.stringify(true)) router.push({ name: 'posts.index' }) } // ... return { loginForm, validationErrors, processing, submitLogin } return { loginForm, validationErrors, processing, submitLogin, user } }
Now, let's build a method to use...
Hi! I like this course so much :)
I found one typo at the end of the lesson: After refreshing the "pag",
Thanks!
Actually, we are using the reactive 'user' object exclusively in the Authenticated component. It's unclear why we need to call 'getUser' after mounting the rootComponent?! It would be more appropriate, in my opinion, to call 'getUser' after mounting the Authenticated component. In this case, you don't need to take the reactive 'user' object out of the exported 'useAuth' function.
Hi! In the getUser method calling the loginUser can make an undesirable redirect.For example Create page refresh will redirect to the Posts page. You can make a showUser method inside it with the response userdata(name, email) and call that in submitLogin and getUser.