forked from AkkomaGang/akkoma-fe
Merge branch 'masto-login-fixes' into 'develop'
MastoAPI login See merge request pleroma/pleroma-fe!805
This commit is contained in:
commit
9df99c5205
3 changed files with 21 additions and 5 deletions
|
@ -44,6 +44,7 @@
|
||||||
<scope-selector
|
<scope-selector
|
||||||
:showAll="true"
|
:showAll="true"
|
||||||
:userDefault="newDefaultScope"
|
:userDefault="newDefaultScope"
|
||||||
|
:initialScope="newDefaultScope"
|
||||||
:onScopeChange="changeVis"/>
|
:onScopeChange="changeVis"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
/* eslint-env browser */
|
/* eslint-env browser */
|
||||||
const LOGIN_URL = '/api/account/verify_credentials.json'
|
|
||||||
const REGISTRATION_URL = '/api/account/register.json'
|
const REGISTRATION_URL = '/api/account/register.json'
|
||||||
const BG_UPDATE_URL = '/api/qvitter/update_background_image.json'
|
const BG_UPDATE_URL = '/api/qvitter/update_background_image.json'
|
||||||
const EXTERNAL_PROFILE_URL = '/api/externalprofile/show.json'
|
const EXTERNAL_PROFILE_URL = '/api/externalprofile/show.json'
|
||||||
|
@ -18,6 +17,7 @@ const ADMIN_USERS_URL = '/api/pleroma/admin/users'
|
||||||
const SUGGESTIONS_URL = '/api/v1/suggestions'
|
const SUGGESTIONS_URL = '/api/v1/suggestions'
|
||||||
const NOTIFICATION_SETTINGS_URL = '/api/pleroma/notification_settings'
|
const NOTIFICATION_SETTINGS_URL = '/api/pleroma/notification_settings'
|
||||||
|
|
||||||
|
const MASTODON_LOGIN_URL = '/api/v1/accounts/verify_credentials'
|
||||||
const MASTODON_USER_FAVORITES_TIMELINE_URL = '/api/v1/favourites'
|
const MASTODON_USER_FAVORITES_TIMELINE_URL = '/api/v1/favourites'
|
||||||
const MASTODON_USER_NOTIFICATIONS_URL = '/api/v1/notifications'
|
const MASTODON_USER_NOTIFICATIONS_URL = '/api/v1/notifications'
|
||||||
const MASTODON_FAVORITE_URL = id => `/api/v1/statuses/${id}/favourite`
|
const MASTODON_FAVORITE_URL = id => `/api/v1/statuses/${id}/favourite`
|
||||||
|
@ -513,8 +513,7 @@ const fetchPinnedStatuses = ({ id, credentials }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const verifyCredentials = (user) => {
|
const verifyCredentials = (user) => {
|
||||||
return fetch(LOGIN_URL, {
|
return fetch(MASTODON_LOGIN_URL, {
|
||||||
method: 'POST',
|
|
||||||
headers: authHeaders(user)
|
headers: authHeaders(user)
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
@ -526,6 +525,7 @@ const verifyCredentials = (user) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
.then((data) => data.error ? data : parseUser(data))
|
.then((data) => data.error ? data : parseUser(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,23 @@ export const parseUser = (data) => {
|
||||||
moderator: data.pleroma.is_moderator,
|
moderator: data.pleroma.is_moderator,
|
||||||
admin: data.pleroma.is_admin
|
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) {
|
||||||
|
output.no_rich_text = data.source.pleroma.no_rich_text
|
||||||
|
output.show_role = data.source.pleroma.show_role
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: handle is_local
|
// TODO: handle is_local
|
||||||
|
@ -105,8 +122,6 @@ export const parseUser = (data) => {
|
||||||
|
|
||||||
output.muted = data.muted
|
output.muted = data.muted
|
||||||
|
|
||||||
// QVITTER ONLY FOR NOW
|
|
||||||
// Really only applies to logged in user, really.. I THINK
|
|
||||||
if (data.rights) {
|
if (data.rights) {
|
||||||
output.rights = {
|
output.rights = {
|
||||||
moderator: data.rights.delete_others_notice,
|
moderator: data.rights.delete_others_notice,
|
||||||
|
|
Loading…
Reference in a new issue