Cambalab / vue-admin

An open source frontend Framework for building admin applications running in the browser on top of REST, using ES6 and Vue.js
GNU General Public License v3.0
132 stars 24 forks source link

User extraction may fail for different backends #197

Open sgobotta opened 4 years ago

sgobotta commented 4 years ago

Describe the bug Vue-Admin and many other administration applications tend to make use of a username to show welcome messagesor any other message that needs a kind of presentation to that individual.

In Vue-Admin there's currently a way to extract the current user, where a username or email can be found, though there's no way to get to know which is the field where this username will be extracted from.

We can notice the authentication system uses authFields:

const authFields = { username: 'username', password: 'password' }

There also this userField variable the authentication adapter will use to extract the user from successful responses:

const userField = 'user'

To Reproduce Steps to reproduce the behavior:

  1. Make sure your backend responds the AUTH_LOGIN_REQUEST with a user without an email field.
  2. Try to log in
  3. The alert system should break because it assumes every extracted user has an email value. The snackbar text welcome has an empty string where the name should be located.

Expected behavior The snackbar, and any other Vue-Admin component should not worry about the user response structure. Vue-Admin should let users define expected attribute fields of the user object in authentication responses