login/logout troubles
This commit is contained in:
parent
08541b672b
commit
55324aea13
4 changed files with 106 additions and 32 deletions
|
|
@ -19,7 +19,14 @@ const MASTODON_REGISTRATION_URL = '/api/v1/accounts'
|
||||||
const MASTODON_PASSWORD_RESET_URL = ({ email }) =>
|
const MASTODON_PASSWORD_RESET_URL = ({ email }) =>
|
||||||
`/auth/password${paramsString({ email })}`
|
`/auth/password${paramsString({ email })}`
|
||||||
|
|
||||||
const MASTODON_USER_NOTIFICATIONS_URL = ({ minId, sinceId, maxId, limit, includeTypes, replyVisibility }) =>
|
const MASTODON_USER_NOTIFICATIONS_URL = ({
|
||||||
|
minId,
|
||||||
|
sinceId,
|
||||||
|
maxId,
|
||||||
|
limit,
|
||||||
|
includeTypes,
|
||||||
|
replyVisibility,
|
||||||
|
}) =>
|
||||||
`/api/v1/notifications${paramsString({ minId, sinceId, maxId, limit, includeTypes, replyVisibility })}`
|
`/api/v1/notifications${paramsString({ minId, sinceId, maxId, limit, includeTypes, replyVisibility })}`
|
||||||
const MASTODON_FOLLOWING_URL = (
|
const MASTODON_FOLLOWING_URL = (
|
||||||
id,
|
id,
|
||||||
|
|
@ -32,27 +39,82 @@ const MASTODON_FOLLOWERS_URL = (
|
||||||
) =>
|
) =>
|
||||||
`/api/v1/accounts/${id}/followers${paramsString({ minId, maxId, sinceId, limit, withRelationships })}`
|
`/api/v1/accounts/${id}/followers${paramsString({ minId, maxId, sinceId, limit, withRelationships })}`
|
||||||
|
|
||||||
const MASTODON_USER_HOME_TIMELINE_URL = ({ minId, sinceId, maxId, limit, replyVisibility }) =>
|
const MASTODON_USER_HOME_TIMELINE_URL = ({
|
||||||
|
minId,
|
||||||
|
sinceId,
|
||||||
|
maxId,
|
||||||
|
limit,
|
||||||
|
replyVisibility,
|
||||||
|
}) =>
|
||||||
`/api/v1/timelines/home${paramsString({ minId, sinceId, maxId, limit, replyVisibility })}`
|
`/api/v1/timelines/home${paramsString({ minId, sinceId, maxId, limit, replyVisibility })}`
|
||||||
const MASTODON_LIST_TIMELINE_URL = (id, { minId, sinceId, maxId, limit, replyVisibility }) =>
|
const MASTODON_LIST_TIMELINE_URL = (
|
||||||
|
id,
|
||||||
|
{ minId, sinceId, maxId, limit, replyVisibility },
|
||||||
|
) =>
|
||||||
`/api/v1/timelines/list/${id}${paramsString({ minId, sinceId, maxId, limit, replyVisibility })}`
|
`/api/v1/timelines/list/${id}${paramsString({ minId, sinceId, maxId, limit, replyVisibility })}`
|
||||||
const MASTODON_DIRECT_MESSAGES_TIMELINE_URL = ({ minId, sinceId, maxId, limit, replyVisibility }) =>
|
const MASTODON_DIRECT_MESSAGES_TIMELINE_URL = ({
|
||||||
|
minId,
|
||||||
|
sinceId,
|
||||||
|
maxId,
|
||||||
|
limit,
|
||||||
|
replyVisibility,
|
||||||
|
}) =>
|
||||||
`/api/v1/timelines/direct${paramsString({ minId, sinceId, maxId, limit, replyVisibility })}`
|
`/api/v1/timelines/direct${paramsString({ minId, sinceId, maxId, limit, replyVisibility })}`
|
||||||
const MASTODON_PUBLIC_TIMELINE = ({ minId, sinceId, maxId, limit, replyVisibility, local, remote, onlyMedia }) =>
|
const MASTODON_PUBLIC_TIMELINE = ({
|
||||||
|
minId,
|
||||||
|
sinceId,
|
||||||
|
maxId,
|
||||||
|
limit,
|
||||||
|
replyVisibility,
|
||||||
|
local,
|
||||||
|
remote,
|
||||||
|
onlyMedia,
|
||||||
|
}) =>
|
||||||
`/api/v1/timelines/public${paramsString({ minId, sinceId, maxId, limit, replyVisibility, local, remote, onlyMedia })}`
|
`/api/v1/timelines/public${paramsString({ minId, sinceId, maxId, limit, replyVisibility, local, remote, onlyMedia })}`
|
||||||
const MASTODON_TAG_TIMELINE_URL = (tag, { minId, sinceId, maxId, limit, replyVisibility }) =>
|
const MASTODON_TAG_TIMELINE_URL = (
|
||||||
|
tag,
|
||||||
|
{ minId, sinceId, maxId, limit, replyVisibility },
|
||||||
|
) =>
|
||||||
`/api/v1/timelines/tag/${tag}${paramsString({ minId, sinceId, maxId, limit, replyVisibility })}`
|
`/api/v1/timelines/tag/${tag}${paramsString({ minId, sinceId, maxId, limit, replyVisibility })}`
|
||||||
const MASTODON_USER_TIMELINE_URL = (id, { minId, sinceId, maxId, limit, replyVisibility, pinned, onlyMedia }) =>
|
const MASTODON_USER_TIMELINE_URL = (
|
||||||
|
id,
|
||||||
|
{ minId, sinceId, maxId, limit, replyVisibility, pinned, onlyMedia },
|
||||||
|
) =>
|
||||||
`/api/v1/accounts/${id}/statuses${paramsString({ minId, sinceId, maxId, limit, replyVisibility, pinned, onlyMedia })}`
|
`/api/v1/accounts/${id}/statuses${paramsString({ minId, sinceId, maxId, limit, replyVisibility, pinned, onlyMedia })}`
|
||||||
const MASTODON_USER_FAVORITES_TIMELINE_URL = ({ minId, sinceId, maxId, limit, replyVisibility }) =>
|
const MASTODON_USER_FAVORITES_TIMELINE_URL = ({
|
||||||
|
minId,
|
||||||
|
sinceId,
|
||||||
|
maxId,
|
||||||
|
limit,
|
||||||
|
replyVisibility,
|
||||||
|
}) =>
|
||||||
`/api/v1/favourites${paramsString({ minId, sinceId, maxId, limit, replyVisibility })}`
|
`/api/v1/favourites${paramsString({ minId, sinceId, maxId, limit, replyVisibility })}`
|
||||||
const MASTODON_BOOKMARK_TIMELINE_URL = ({ minId, sinceId, maxId, limit, replyVisibility, folderId }) =>
|
const MASTODON_BOOKMARK_TIMELINE_URL = ({
|
||||||
|
minId,
|
||||||
|
sinceId,
|
||||||
|
maxId,
|
||||||
|
limit,
|
||||||
|
replyVisibility,
|
||||||
|
folderId,
|
||||||
|
}) =>
|
||||||
`/api/v1/bookmarks${paramsString({ minId, sinceId, maxId, limit, replyVisibility, folderId })}`
|
`/api/v1/bookmarks${paramsString({ minId, sinceId, maxId, limit, replyVisibility, folderId })}`
|
||||||
const PLEROMA_STATUS_QUOTES_URL = (id, { minId, sinceId, maxId, limit, replyVisibility }) =>
|
const PLEROMA_STATUS_QUOTES_URL = (
|
||||||
|
id,
|
||||||
|
{ minId, sinceId, maxId, limit, replyVisibility },
|
||||||
|
) =>
|
||||||
`/api/v1/pleroma/statuses/${id}/quotes${paramsString({ minId, sinceId, maxId, limit, replyVisibility })}`
|
`/api/v1/pleroma/statuses/${id}/quotes${paramsString({ minId, sinceId, maxId, limit, replyVisibility })}`
|
||||||
const PLEROMA_USER_FAVORITES_TIMELINE_URL = (id, { minId, sinceId, maxId, limit, replyVisibility }) =>
|
const PLEROMA_USER_FAVORITES_TIMELINE_URL = (
|
||||||
|
id,
|
||||||
|
{ minId, sinceId, maxId, limit, replyVisibility },
|
||||||
|
) =>
|
||||||
`/api/v1/pleroma/accounts/${id}/favourites${paramsString({ minId, sinceId, maxId, limit, replyVisibility })}`
|
`/api/v1/pleroma/accounts/${id}/favourites${paramsString({ minId, sinceId, maxId, limit, replyVisibility })}`
|
||||||
const AKKOMA_BUBBLE_TIMELINE_URL = ({ minId, sinceId, maxId, limit, replyVisibility }) =>
|
const AKKOMA_BUBBLE_TIMELINE_URL = ({
|
||||||
|
minId,
|
||||||
|
sinceId,
|
||||||
|
maxId,
|
||||||
|
limit,
|
||||||
|
replyVisibility,
|
||||||
|
}) =>
|
||||||
`/api/v1/timelines/bubble${paramsString({ minId, sinceId, maxId, limit, replyVisibility })}`
|
`/api/v1/timelines/bubble${paramsString({ minId, sinceId, maxId, limit, replyVisibility })}`
|
||||||
|
|
||||||
export const MASTODON_STATUS_URL = (id) => `/api/v1/statuses/${id}`
|
export const MASTODON_STATUS_URL = (id) => `/api/v1/statuses/${id}`
|
||||||
|
|
@ -66,10 +128,22 @@ const MASTODON_STATUS_FAVORITEDBY_URL = (id) =>
|
||||||
`/api/v1/statuses/${id}/favourited_by`
|
`/api/v1/statuses/${id}/favourited_by`
|
||||||
const MASTODON_STATUS_REBLOGGEDBY_URL = (id) =>
|
const MASTODON_STATUS_REBLOGGEDBY_URL = (id) =>
|
||||||
`/api/v1/statuses/${id}/reblogged_by`
|
`/api/v1/statuses/${id}/reblogged_by`
|
||||||
const MASTODON_SEARCH_2 = ({ q, resolve, limit, offset, following, type, withRelationships, accountId, excludeUnreviewed }) =>
|
const MASTODON_SEARCH_2 = ({
|
||||||
|
q,
|
||||||
|
resolve,
|
||||||
|
limit,
|
||||||
|
offset,
|
||||||
|
following,
|
||||||
|
type,
|
||||||
|
withRelationships,
|
||||||
|
accountId,
|
||||||
|
excludeUnreviewed,
|
||||||
|
}) =>
|
||||||
`/api/v2/search${paramsString({ q, resolve, limit, offset, following, type, withRelationships, accountId, excludeUnreviewed })}`
|
`/api/v2/search${paramsString({ q, resolve, limit, offset, following, type, withRelationships, accountId, excludeUnreviewed })}`
|
||||||
const MASTODON_USER_SEARCH_URL = ({ q, resolve }) => `/api/v1/accounts/search${paramsString({ q, resolve })}`
|
const MASTODON_USER_SEARCH_URL = ({ q, resolve }) =>
|
||||||
const MASTODON_STREAMING = ({ accessToken, stream }) => `/api/v1/streaming${paramsString({accessToken, stream })}`
|
`/api/v1/accounts/search${paramsString({ q, resolve })}`
|
||||||
|
const MASTODON_STREAMING = ({ accessToken, stream }) =>
|
||||||
|
`/api/v1/streaming${paramsString({ accessToken, stream })}`
|
||||||
const MASTODON_KNOWN_DOMAIN_LIST_URL = '/api/v1/instance/peers'
|
const MASTODON_KNOWN_DOMAIN_LIST_URL = '/api/v1/instance/peers'
|
||||||
const PLEROMA_EMOJI_REACTIONS_URL = (id) =>
|
const PLEROMA_EMOJI_REACTIONS_URL = (id) =>
|
||||||
`/api/v1/pleroma/statuses/${id}/reactions`
|
`/api/v1/pleroma/statuses/${id}/reactions`
|
||||||
|
|
@ -246,7 +320,7 @@ export const fetchTimeline = ({
|
||||||
'list',
|
'list',
|
||||||
'publicFavorites',
|
'publicFavorites',
|
||||||
'tag',
|
'tag',
|
||||||
'quotes'
|
'quotes',
|
||||||
])
|
])
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
|
|
@ -414,10 +488,7 @@ export const search2 = ({
|
||||||
export const fetchKnownDomains = ({ credentials }) =>
|
export const fetchKnownDomains = ({ credentials }) =>
|
||||||
promisedRequest({ url: MASTODON_KNOWN_DOMAIN_LIST_URL, credentials })
|
promisedRequest({ url: MASTODON_KNOWN_DOMAIN_LIST_URL, credentials })
|
||||||
|
|
||||||
export const getMastodonSocketURI = (
|
export const getMastodonSocketURI = ({ credentials, stream }, base) => {
|
||||||
{ credentials, stream },
|
|
||||||
base,
|
|
||||||
) => {
|
|
||||||
return base + MASTODON_STREAMING({ accessToken: credentials, stream })
|
return base + MASTODON_STREAMING({ accessToken: credentials, stream })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,25 +56,26 @@ const LoginForm = {
|
||||||
instance: this.server,
|
instance: this.server,
|
||||||
username: this.user.username,
|
username: this.user.username,
|
||||||
password: this.user.password,
|
password: this.user.password,
|
||||||
}).then((result) => {
|
})
|
||||||
if (result.error) {
|
.then(({ data: result }) => {
|
||||||
if (result.error === 'mfa_required') {
|
this.login(result).then(() => {
|
||||||
this.requireMFA({ settings: result })
|
this.$router.push({ name: 'friends' })
|
||||||
} else if (result.identifier === 'password_reset_required') {
|
})
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
if (error === 'mfa_required') {
|
||||||
|
this.requireMFA({ settings: error })
|
||||||
|
} else if (error.identifier === 'password_reset_required') {
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
name: 'password-reset',
|
name: 'password-reset',
|
||||||
params: { passwordResetRequested: true },
|
params: { passwordResetRequested: true },
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.error = result.error
|
this.error = error
|
||||||
this.focusOnPasswordInput()
|
this.focusOnPasswordInput()
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
|
||||||
this.login(result).then(() => {
|
|
||||||
this.$router.push({ name: 'friends' })
|
|
||||||
})
|
})
|
||||||
})
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
clearError() {
|
clearError() {
|
||||||
|
|
|
||||||
|
|
@ -792,7 +792,7 @@ const statuses = {
|
||||||
fetchRebloggedByUsers({
|
fetchRebloggedByUsers({
|
||||||
id,
|
id,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then(({ data }) => data),,
|
}).then(({ data }) => data),
|
||||||
]).then(([favoritedByUsers, rebloggedByUsers]) => {
|
]).then(([favoritedByUsers, rebloggedByUsers]) => {
|
||||||
commit('addFavs', {
|
commit('addFavs', {
|
||||||
id,
|
id,
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import Cookies from 'js-cookie'
|
||||||
import {
|
import {
|
||||||
compact,
|
compact,
|
||||||
concat,
|
concat,
|
||||||
|
|
@ -717,7 +718,6 @@ const users = {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
store.commit('clearCurrentUser')
|
store.commit('clearCurrentUser')
|
||||||
store.dispatch('disconnectFromSocket')
|
store.dispatch('disconnectFromSocket')
|
||||||
oauth.clearToken()
|
|
||||||
store.dispatch('stopFetchingTimeline', 'friends')
|
store.dispatch('stopFetchingTimeline', 'friends')
|
||||||
store.dispatch('stopFetchingNotifications')
|
store.dispatch('stopFetchingNotifications')
|
||||||
useListsStore().stopFetching()
|
useListsStore().stopFetching()
|
||||||
|
|
@ -726,6 +726,8 @@ const users = {
|
||||||
store.commit('clearNotifications')
|
store.commit('clearNotifications')
|
||||||
store.commit('resetStatuses')
|
store.commit('resetStatuses')
|
||||||
store.dispatch('resetChats')
|
store.dispatch('resetChats')
|
||||||
|
oauth.clearToken()
|
||||||
|
Cookies.remove('__Host-pleroma_key', { path: '/' })
|
||||||
useInterfaceStore().setLastTimeline('public-timeline')
|
useInterfaceStore().setLastTimeline('public-timeline')
|
||||||
useInterfaceStore().setLayoutWidth(windowWidth())
|
useInterfaceStore().setLayoutWidth(windowWidth())
|
||||||
useInterfaceStore().setLayoutHeight(windowHeight())
|
useInterfaceStore().setLayoutHeight(windowHeight())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue