moeen-basra / laravel-react

Laravel 8 and React 17 boilerplate

Home Page:http://laravel-react.moeen.me/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The user name does't appear after first login

geniux300 opened this issue · comments

Hi everyone,
First thing first, I want to say that this is a fantastic project which has been really helpful.
I have found a problem related to the login. As you are able to see in the followings picture 1, (I am using the published web for exposing the problem), after login with a new account by first time, the website does not show the name of the user in the top right corner.

image
Figure 1

That problem is fixed pressing F5 button (Figure 2), but is pretty cumbersome. So I want to know if there is some way to solve that problem. Everything works well, but this bug spoil the user’s experience.

image
Figure 2
Thanks a lot
Regards

Does anyone know how to solve that problem in the code?
I'd appreciate it any help

@geniux300 This little change should do the trick :)

diff --git a/resources/assets/js/modules/auth/service.js b/resources/assets/js/modules/auth/service.js
index 110ecc3..de4110b 100644
--- a/resources/assets/js/modules/auth/service.js
+++ b/resources/assets/js/modules/auth/service.js
@@ -33,6 +33,7 @@ export function login(credentials) {
         .then(res => {
           const data = Transformer.fetch(res.data)
           dispatch(authActions.authLogin(data.accessToken))
+          dispatch(fetchUser())
           return resolve()
         })
         .catch((err) => {
commented

@geniux300 follow the guide provided by @jacekk. I'm currently busy with a new release.

Thanks a lot. It works perfectly.