diff --git a/src/api/__mocks__/login.js b/src/api/__mocks__/login.js index 9f1bfeb1..a94fae9b 100644 --- a/src/api/__mocks__/login.js +++ b/src/api/__mocks__/login.js @@ -42,7 +42,7 @@ export function getUserInfo(token, authHost) { 'statuses_count': 0, 'cover_photo': '', 'hide_follows': false, - 'pleroma': { 'confirmation_pending': false, 'deactivated': false, 'tags': ['force_nsfw'] }, + 'pleroma': { 'confirmation_pending': false, 'deactivated': false, 'tags': ['force_nsfw'], 'is_admin': true }, 'profile_image_url_original': '', 'created_at': 'Fri Mar 01 15:15:19 +0000 2019', 'fields': [], diff --git a/src/api/login.js b/src/api/login.js index adaabd54..d5ef3b38 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -32,8 +32,8 @@ export async function loginByUsername(username, password, authHost) { export function getUserInfo(token, authHost) { return request({ baseURL: baseName(authHost), - url: '/api/account/verify_credentials', - method: 'post', + url: '/api/v1/accounts/verify_credentials', + method: 'get', headers: token ? { 'Authorization': `Bearer ${token}` } : {} }) } diff --git a/src/permission.js b/src/permission.js index 1439b1b9..7dbf3c47 100644 --- a/src/permission.js +++ b/src/permission.js @@ -26,7 +26,7 @@ export const beforeEachRoute = (to, from, next) => { } else { if (store.getters.roles.length === 0) { store.dispatch('GetUserInfo').then(res => { - const roles = res.data.rights.admin ? ['admin'] : [] + const roles = res.data.pleroma.is_admin ? ['admin'] : [] store.dispatch('GenerateRoutes', { roles }).then(() => { router.addRoutes(store.getters.addRouters) next({ ...to, replace: true }) diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 8c282e71..2a81fcb4 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -77,15 +77,15 @@ const user = { reject('Verification failed, please login again.') } - if (data.rights && data.rights.admin) { + if (data.pleroma && data.pleroma.is_admin) { commit('SET_ROLES', ['admin']) } else { reject('getInfo: roles must be a non-null array!') } - commit('SET_NAME', data.name) + commit('SET_NAME', data.username) commit('SET_ID', data.id) - commit('SET_AVATAR', data.profile_image_url) + commit('SET_AVATAR', data.avatar) commit('SET_INTRODUCTION', '') resolve(response) }).catch(error => { diff --git a/src/views/users/index.vue b/src/views/users/index.vue index f2691581..4a186ae3 100644 --- a/src/views/users/index.vue +++ b/src/views/users/index.vue @@ -3,7 +3,7 @@