PetroGromovo
4 days ago
42
1
Vue

How to add custom fields to logged user to vue side?

Posted 4 days ago by PetroGromovo

Hello,

In my Laravel 5.8 / vuejs 2.6 / vuex 3.1 I want to add custom fields to logged user based on personal data and methods defined in user Model I use next method which is called from login.vue page:

  export function login(credentials) {
       return new Promise((res, rej) => {
           axios.post('/api/auth/login', credentials)
               .then((response) => {
                   console.log("+++ credentials::")
                   console.log( credentials )
   
                   console.log("+++ response::")
                   console.log( response )
                   setAuthorizationToken(response.data.access_token);
                   res(response.data);
               })
               .catch((err) =>{
                   rej("Wrong email or password");
               })
       })
   }

and standart app/Http/Controllers/Auth/LoginController.php file, where login method ios not defined. How can I on laravel side catch after login event, assign custom fields and return them to Promise method above ?

Thanks!

Please sign in or create an account to participate in this conversation.