Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Error in JWT auth provider #7

Open
nonsintetic opened this issue Nov 17, 2020 · 0 comments
Open

Error in JWT auth provider #7

nonsintetic opened this issue Nov 17, 2020 · 0 comments

Comments

@nonsintetic
Copy link

nonsintetic commented Nov 17, 2020

The CHECK_AUTH method in the JWT auth provider returns response.data, when a "user" route is provided in configuration.

/**
  * Get user infos
  */
  if (routes.user) {
        let response = await httpClient.get(routes.user);

        if (response.status < 200 || response.status >= 300) {
          throw new Error(response.statusText);
        }
        return response.data;
  }

But then in store/auth.js it's commiting the "setUser" mutation using response.data as a parameter again:

[CHECK_AUTH]: async ({ commit }) => {
        try {
          let response = await provider[CHECK_AUTH]();
          if (response) {
            commit("setUser", response.data);
          }
          return response.data;
        } catch (e) {
          commit("setUser", null);
        }
      },

This means incoming data from the axios request would have to be response.data.data. I believe that's an error. In store/auth.js it should just commit "setUser" with the parameter response, since it's already containing the user data at this point.

As is I'm getting redirected to the login screen despite logging in successfully (token is set in localStorage) whenever I set a route to get the "user" data from.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant