forked from AkkomaGang/akkoma-fe
mastoapi login works
This commit is contained in:
parent
233506f6c1
commit
fc12b63fcc
3 changed files with 25 additions and 5 deletions
|
@ -44,6 +44,7 @@
|
|||
<scope-selector
|
||||
:showAll="true"
|
||||
:userDefault="newDefaultScope"
|
||||
:initialScope="newDefaultScope"
|
||||
:onScopeChange="changeVis"/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/* eslint-env browser */
|
||||
const LOGIN_URL = '/api/account/verify_credentials.json'
|
||||
const REGISTRATION_URL = '/api/account/register.json'
|
||||
const BG_UPDATE_URL = '/api/qvitter/update_background_image.json'
|
||||
const EXTERNAL_PROFILE_URL = '/api/externalprofile/show.json'
|
||||
|
@ -17,6 +16,7 @@ const ACTIVATION_STATUS_URL = screenName => `/api/pleroma/admin/users/${screenNa
|
|||
const ADMIN_USERS_URL = '/api/pleroma/admin/users'
|
||||
const SUGGESTIONS_URL = '/api/v1/suggestions'
|
||||
|
||||
const MASTODON_LOGIN_URL = '/api/v1/accounts/verify_credentials'
|
||||
const MASTODON_USER_FAVORITES_TIMELINE_URL = '/api/v1/favourites'
|
||||
const MASTODON_USER_NOTIFICATIONS_URL = '/api/v1/notifications'
|
||||
const MASTODON_FAVORITE_URL = id => `/api/v1/statuses/${id}/favourite`
|
||||
|
@ -497,8 +497,7 @@ const fetchPinnedStatuses = ({ id, credentials }) => {
|
|||
}
|
||||
|
||||
const verifyCredentials = (user) => {
|
||||
return fetch(LOGIN_URL, {
|
||||
method: 'POST',
|
||||
return fetch(MASTODON_LOGIN_URL, {
|
||||
headers: authHeaders(user)
|
||||
})
|
||||
.then((response) => {
|
||||
|
@ -510,6 +509,7 @@ const verifyCredentials = (user) => {
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
.then((data) => data.error ? data : parseUser(data))
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,27 @@ export const parseUser = (data) => {
|
|||
moderator: data.pleroma.is_moderator,
|
||||
admin: data.pleroma.is_admin
|
||||
}
|
||||
// TODO: Clean up in UI? This is duplication from what BE does for qvitterapi
|
||||
if (output.rights.admin) {
|
||||
output.role = 'admin'
|
||||
} else if (output.rights.moderator) {
|
||||
output.role = 'moderator'
|
||||
} else {
|
||||
output.role = 'member'
|
||||
}
|
||||
}
|
||||
|
||||
if (data.source) {
|
||||
output.description = data.source.note
|
||||
output.default_scope = data.source.privacy
|
||||
if (data.source.pleroma) {
|
||||
if (data.source.pleroma.show_role) {
|
||||
console.log(data.source)
|
||||
console.log(data.pleroma)
|
||||
}
|
||||
output.no_rich_text = data.source.pleroma.no_rich_text
|
||||
output.show_role = data.source.pleroma.show_role
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: handle is_local
|
||||
|
@ -106,8 +127,6 @@ export const parseUser = (data) => {
|
|||
|
||||
output.muted = data.muted
|
||||
|
||||
// QVITTER ONLY FOR NOW
|
||||
// Really only applies to logged in user, really.. I THINK
|
||||
if (data.rights) {
|
||||
output.rights = {
|
||||
moderator: data.rights.delete_others_notice,
|
||||
|
|
Loading…
Reference in a new issue