Replace deprecated login API

This commit is contained in:
Angelina Filippova 2019-05-21 19:24:48 +00:00 committed by feld
parent f9a17d6837
commit 0667d92d2a
5 changed files with 13 additions and 8 deletions

View file

@ -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': [],

View file

@ -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}` } : {}
})
}

View file

@ -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 })

View file

@ -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 => {

View file

@ -3,7 +3,7 @@
<h1>{{ $t('users.users') }}</h1>
<div class="search-container">
<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>
<el-table v-loading="loading" :data="users" style="width: 100%">
<el-table-column :min-width="width" :label="$t('users.id')" prop="id" />
@ -124,6 +124,11 @@ export default {
components: {
UsersFilter
},
data() {
return {
search: ''
}
},
computed: {
loading() {
return this.$store.state.users.loading