Merge branch 'fix-mfa' into 'develop'

Fix MFA forms

See merge request pleroma/pleroma-fe!2105
This commit is contained in:
HJ 2025-03-26 12:33:34 +00:00
commit 1272c3e905
5 changed files with 30 additions and 6 deletions

View file

View file

@ -1,5 +1,7 @@
import mfaApi from '../../services/new_api/mfa.js' import mfaApi from '../../services/new_api/mfa.js'
import { mapState, mapGetters, mapActions, mapMutations } from 'vuex' import { mapState, mapGetters, mapActions, mapMutations } from 'vuex'
import { mapStores } from 'pinia'
import { useOAuthStore } from 'src/stores/oauth.js'
import { library } from '@fortawesome/fontawesome-svg-core' import { library } from '@fortawesome/fontawesome-svg-core'
import { import {
faTimes faTimes
@ -18,17 +20,24 @@ export default {
...mapGetters({ ...mapGetters({
authSettings: 'authFlow/settings' authSettings: 'authFlow/settings'
}), }),
...mapStores(useOAuthStore),
...mapState({ ...mapState({
instance: 'instance', instance: 'instance',
oauth: 'oauth'
}) })
}, },
methods: { methods: {
...mapMutations('authFlow', ['requireTOTP', 'abortMFA']), ...mapMutations('authFlow', ['requireTOTP', 'abortMFA']),
...mapActions({ login: 'authFlow/login' }), ...mapActions({ login: 'authFlow/login' }),
clearError () { this.error = false }, clearError () { this.error = false },
focusOnCodeInput () {
const codeInput = this.$refs.codeInput
codeInput.focus()
codeInput.setSelectionRange(0, codeInput.value.length)
},
submit () { submit () {
const { clientId, clientSecret } = this.oauth const { clientId, clientSecret } = this.oauthStore
const data = { const data = {
clientId, clientId,
@ -42,6 +51,7 @@ export default {
if (result.error) { if (result.error) {
this.error = result.error this.error = result.error
this.code = null this.code = null
this.focusOnCodeInput()
return return
} }

View file

@ -1,5 +1,5 @@
<template> <template>
<div class="login panel panel-default"> <div class="login-panel panel panel-default">
<!-- Default panel contents --> <!-- Default panel contents -->
<div class="panel-heading"> <div class="panel-heading">
@ -17,6 +17,7 @@
<label for="code">{{ $t('login.recovery_code') }}</label> <label for="code">{{ $t('login.recovery_code') }}</label>
<input <input
id="code" id="code"
ref="codeInput"
v-model="code" v-model="code"
class="input form-control" class="input form-control"
> >
@ -71,4 +72,5 @@
</div> </div>
</div> </div>
</template> </template>
<script src="./recovery_form.js"></script> <script src="./recovery_form.js"></script>

View file

@ -1,5 +1,7 @@
import mfaApi from '../../services/new_api/mfa.js' import mfaApi from '../../services/new_api/mfa.js'
import { mapState, mapGetters, mapActions, mapMutations } from 'vuex' import { mapState, mapGetters, mapActions, mapMutations } from 'vuex'
import { mapStores } from 'pinia'
import { useOAuthStore } from 'src/stores/oauth.js'
import { library } from '@fortawesome/fontawesome-svg-core' import { library } from '@fortawesome/fontawesome-svg-core'
import { import {
faTimes faTimes
@ -18,17 +20,24 @@ export default {
...mapGetters({ ...mapGetters({
authSettings: 'authFlow/settings' authSettings: 'authFlow/settings'
}), }),
...mapStores(useOAuthStore),
...mapState({ ...mapState({
instance: 'instance', instance: 'instance',
oauth: 'oauth'
}) })
}, },
methods: { methods: {
...mapMutations('authFlow', ['requireRecovery', 'abortMFA']), ...mapMutations('authFlow', ['requireRecovery', 'abortMFA']),
...mapActions({ login: 'authFlow/login' }), ...mapActions({ login: 'authFlow/login' }),
clearError () { this.error = false }, clearError () { this.error = false },
focusOnCodeInput () {
const codeInput = this.$refs.codeInput
codeInput.focus()
codeInput.setSelectionRange(0, codeInput.value.length)
},
submit () { submit () {
const { clientId, clientSecret } = this.oauth const { clientId, clientSecret } = this.oauthStore
const data = { const data = {
clientId, clientId,
@ -42,6 +51,7 @@ export default {
if (result.error) { if (result.error) {
this.error = result.error this.error = result.error
this.code = null this.code = null
this.focusOnCodeInput()
return return
} }

View file

@ -1,5 +1,5 @@
<template> <template>
<div class="login panel panel-default"> <div class="login-panel panel panel-default">
<!-- Default panel contents --> <!-- Default panel contents -->
<div class="panel-heading"> <div class="panel-heading">
@ -19,6 +19,7 @@
</label> </label>
<input <input
id="code" id="code"
ref="codeInput"
v-model="code" v-model="code"
class="input form-control" class="input form-control"
> >
@ -74,4 +75,5 @@
</div> </div>
</div> </div>
</template> </template>
<script src="./totp_form.js"></script> <script src="./totp_form.js"></script>