feat: get data from jwt

This commit is contained in:
caturbgs
2021-12-09 23:18:54 +07:00
parent 4846e7022a
commit ed42cb6c0c
4 changed files with 8 additions and 6 deletions

View File

@@ -41,6 +41,7 @@ export class Authentication {
try {
const result = await http.post('/auth/login').send({username, password});
this.accessToken = result.body.access_token;
TokenUtil.setAccessToken(result.body.access_token);
TokenUtil.persistToken();
runInAction(() => {
@@ -60,5 +61,6 @@ export class Authentication {
TokenUtil.clearAccessToken();
TokenUtil.persistToken();
this.isLoggedIn = false;
this.accessToken = '';
}
}

View File

@@ -18,6 +18,7 @@ export class Store {
TokenUtil.loadToken();
if (TokenUtil.accessToken) {
this.authentication.isLoggedIn = true;
this.authentication.accessToken = TokenUtil.accessToken;
}
}
}

View File

@@ -15,8 +15,6 @@ export class Product {
@action
async getData() {
const response = await http.get(`/product?page=${this.page}&pageSize=${this.pageSize}`);
console.log(response, 'Data')
console.log(JSON.stringify(response.body.data), 'Data')
this.data = response.body.data ?? []
this.total_data = response.body.total_data ?? 0