forked from AkkomaGang/admin-fe
Replace deprecated login API
This commit is contained in:
parent
f9a17d6837
commit
0667d92d2a
5 changed files with 13 additions and 8 deletions
|
@ -42,7 +42,7 @@ export function getUserInfo(token, authHost) {
|
||||||
'statuses_count': 0,
|
'statuses_count': 0,
|
||||||
'cover_photo': '',
|
'cover_photo': '',
|
||||||
'hide_follows': false,
|
'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': '',
|
'profile_image_url_original': '',
|
||||||
'created_at': 'Fri Mar 01 15:15:19 +0000 2019',
|
'created_at': 'Fri Mar 01 15:15:19 +0000 2019',
|
||||||
'fields': [],
|
'fields': [],
|
||||||
|
|
|
@ -32,8 +32,8 @@ export async function loginByUsername(username, password, authHost) {
|
||||||
export function getUserInfo(token, authHost) {
|
export function getUserInfo(token, authHost) {
|
||||||
return request({
|
return request({
|
||||||
baseURL: baseName(authHost),
|
baseURL: baseName(authHost),
|
||||||
url: '/api/account/verify_credentials',
|
url: '/api/v1/accounts/verify_credentials',
|
||||||
method: 'post',
|
method: 'get',
|
||||||
headers: token ? { 'Authorization': `Bearer ${token}` } : {}
|
headers: token ? { 'Authorization': `Bearer ${token}` } : {}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ export const beforeEachRoute = (to, from, next) => {
|
||||||
} else {
|
} else {
|
||||||
if (store.getters.roles.length === 0) {
|
if (store.getters.roles.length === 0) {
|
||||||
store.dispatch('GetUserInfo').then(res => {
|
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(() => {
|
store.dispatch('GenerateRoutes', { roles }).then(() => {
|
||||||
router.addRoutes(store.getters.addRouters)
|
router.addRoutes(store.getters.addRouters)
|
||||||
next({ ...to, replace: true })
|
next({ ...to, replace: true })
|
||||||
|
|
|
@ -77,15 +77,15 @@ const user = {
|
||||||
reject('Verification failed, please login again.')
|
reject('Verification failed, please login again.')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.rights && data.rights.admin) {
|
if (data.pleroma && data.pleroma.is_admin) {
|
||||||
commit('SET_ROLES', ['admin'])
|
commit('SET_ROLES', ['admin'])
|
||||||
} else {
|
} else {
|
||||||
reject('getInfo: roles must be a non-null array!')
|
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_ID', data.id)
|
||||||
commit('SET_AVATAR', data.profile_image_url)
|
commit('SET_AVATAR', data.avatar)
|
||||||
commit('SET_INTRODUCTION', '')
|
commit('SET_INTRODUCTION', '')
|
||||||
resolve(response)
|
resolve(response)
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<h1>{{ $t('users.users') }}</h1>
|
<h1>{{ $t('users.users') }}</h1>
|
||||||
<div class="search-container">
|
<div class="search-container">
|
||||||
<users-filter/>
|
<users-filter/>
|
||||||
<el-input :placeholder="$t('users.search')" class="search" @input="handleDebounceSearchInput"/>
|
<el-input :placeholder="$t('users.search')" v-model="search" class="search" @input="handleDebounceSearchInput"/>
|
||||||
</div>
|
</div>
|
||||||
<el-table v-loading="loading" :data="users" style="width: 100%">
|
<el-table v-loading="loading" :data="users" style="width: 100%">
|
||||||
<el-table-column :min-width="width" :label="$t('users.id')" prop="id" />
|
<el-table-column :min-width="width" :label="$t('users.id')" prop="id" />
|
||||||
|
@ -124,6 +124,11 @@ export default {
|
||||||
components: {
|
components: {
|
||||||
UsersFilter
|
UsersFilter
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
search: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
loading() {
|
loading() {
|
||||||
return this.$store.state.users.loading
|
return this.$store.state.users.loading
|
||||||
|
|
Loading…
Reference in a new issue