pass 3 - mapState updates

This commit is contained in:
Henry Jameson 2026-01-29 13:06:19 +02:00
commit 617613dfb4
5 changed files with 24 additions and 36 deletions

View file

@ -17,23 +17,16 @@ const LoginForm = {
error: false, error: false,
}), }),
computed: { computed: {
isPasswordAuth() { ...mapState(useInstanceStore, ['server'])
return this.requiredPassword
},
isTokenAuth() {
return this.requiredToken
},
...mapStores(useOAuthStore), ...mapStores(useOAuthStore),
...mapState({ ...mapState({
registrationOpen: (state) => useInstanceStore().registrationOpen, registrationOpen: (state) => useInstanceStore().registrationOpen,
instance: (state) => useInstanceStore(),
loggingIn: (state) => state.users.loggingIn, loggingIn: (state) => state.users.loggingIn,
}), }),
...mapPiniaState(useAuthFlowStore, [ ...mapPiniaState(useAuthFlowStore, {
'requiredPassword', isTokenAuth: (store) => store.requiredToken,
'requiredToken', isPasswordAuth: (store) => !store.requiredToken,
'requiredMFA', }),
]),
}, },
methods: { methods: {
...mapActions(useAuthFlowStore, ['requireMFA', 'login']), ...mapActions(useAuthFlowStore, ['requireMFA', 'login']),
@ -42,7 +35,7 @@ const LoginForm = {
}, },
submitToken() { submitToken() {
const data = { const data = {
instance: this.instance.server, instance: this.server,
commit: this.$store.commit, commit: this.$store.commit,
} }
@ -70,7 +63,7 @@ const LoginForm = {
oauthApi oauthApi
.getTokenWithCredentials({ .getTokenWithCredentials({
...app, ...app,
instance: this.instance.server, instance: this.server,
username: this.user.username, username: this.user.username,
password: this.user.password, password: this.user.password,
}) })

View file

@ -1,7 +1,7 @@
import { mapActions, mapState as mapPiniaState, mapStores } from 'pinia' import { mapActions, mapState, mapStores } from 'pinia'
import { mapState } from 'vuex'
import { useAuthFlowStore } from 'src/stores/auth_flow.js' import { useAuthFlowStore } from 'src/stores/auth_flow.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { useOAuthStore } from 'src/stores/oauth.js' import { useOAuthStore } from 'src/stores/oauth.js'
import mfaApi from '../../services/new_api/mfa.js' import mfaApi from '../../services/new_api/mfa.js'
@ -16,13 +16,10 @@ export default {
error: false, error: false,
}), }),
computed: { computed: {
...mapPiniaState(useAuthFlowStore, {
authSettings: (store) => store.settings,
}),
...mapStores(useOAuthStore), ...mapStores(useOAuthStore),
...mapState({ ...mapState(useOAuthStore, ['clientId','clientSecret']),
instance: 'instance', ...mapState(useAuthFlowStore, ['settings']),
}), ...mapState(useInstanceStore, ['server']),
}, },
methods: { methods: {
...mapActions(useAuthFlowStore, ['requireTOTP', 'abortMFA', 'login']), ...mapActions(useAuthFlowStore, ['requireTOTP', 'abortMFA', 'login']),
@ -37,13 +34,11 @@ export default {
}, },
submit() { submit() {
const { clientId, clientSecret } = this.oauthStore
const data = { const data = {
clientId, clientId: this.clientId,
clientSecret, clientSecret: this.clientSecret,
instance: this.instance.server, instance: this.server,
mfaToken: this.authSettings.mfa_token, mfaToken: this.settings.mfa_token,
code: this.code, code: this.code,
} }

View file

@ -1,7 +1,7 @@
import { mapActions, mapState as mapPiniaState, mapStores } from 'pinia' import { mapActions, mapState, mapStores } from 'pinia'
import { mapState } from 'vuex'
import { useAuthFlowStore } from 'src/stores/auth_flow.js' import { useAuthFlowStore } from 'src/stores/auth_flow.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { useOAuthStore } from 'src/stores/oauth.js' import { useOAuthStore } from 'src/stores/oauth.js'
import mfaApi from '../../services/new_api/mfa.js' import mfaApi from '../../services/new_api/mfa.js'
@ -16,9 +16,10 @@ export default {
error: false, error: false,
}), }),
computed: { computed: {
...mapPiniaState(useAuthFlowStore, { ...mapState(useAuthFlowStore, {
authSettings: (store) => store.settings, authSettings: (store) => store.settings,
}), }),
...mapState(useInstanceStore, ['server'])
...mapStores(useOAuthStore), ...mapStores(useOAuthStore),
...mapState({ ...mapState({
instance: 'instance', instance: 'instance',
@ -42,7 +43,7 @@ export default {
const data = { const data = {
clientId, clientId,
clientSecret, clientSecret,
instance: this.instance.server, instance: this.server,
mfaToken: this.authSettings.mfa_token, mfaToken: this.authSettings.mfa_token,
code: this.code, code: this.code,
} }

View file

@ -23,9 +23,9 @@ const passwordReset = {
...mapState({ ...mapState({
signedIn: (state) => !!state.users.currentUser, signedIn: (state) => !!state.users.currentUser,
}), }),
...mapPiniaState(useInstanceStore, ['server']), ...mapPiniaState(useInstanceStore, ['server', 'mailerEnabled']),
mailerEnabled() { mailerEnabled() {
return this.instance.mailerEnabled return this.mailerEnabled
}, },
}, },
created() { created() {

View file

@ -646,7 +646,6 @@ const users = {
logout(store) { logout(store) {
const oauth = useOAuthStore() const oauth = useOAuthStore()
const { instance } = store.rootState
// NOTE: No need to verify the app still exists, because if it doesn't, // NOTE: No need to verify the app still exists, because if it doesn't,
// the token will be invalid too // the token will be invalid too
@ -655,7 +654,7 @@ const users = {
.then((app) => { .then((app) => {
const params = { const params = {
app, app,
instance: instance.server, instance: useInstanceStore().server,
token: oauth.userToken, token: oauth.userToken,
} }