Page MenuHomePhorge

No OneTemporary

Authored By
Unknown
Size
8 KB
Referenced Files
None
Subscribers
None
diff --git a/changelog.d/pinia-oauth-mfa.skip b/changelog.d/pinia-oauth-mfa.skip
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/src/components/mfa_form/recovery_form.js b/src/components/mfa_form/recovery_form.js
index 01a62a503c..2d0f4fdff5 100644
--- a/src/components/mfa_form/recovery_form.js
+++ b/src/components/mfa_form/recovery_form.js
@@ -1,54 +1,64 @@
import mfaApi from '../../services/new_api/mfa.js'
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 {
faTimes
} from '@fortawesome/free-solid-svg-icons'
library.add(
faTimes
)
export default {
data: () => ({
code: null,
error: false
}),
computed: {
...mapGetters({
authSettings: 'authFlow/settings'
}),
+ ...mapStores(useOAuthStore),
...mapState({
instance: 'instance',
- oauth: 'oauth'
})
},
methods: {
...mapMutations('authFlow', ['requireTOTP', 'abortMFA']),
...mapActions({ login: 'authFlow/login' }),
clearError () { this.error = false },
+
+ focusOnCodeInput () {
+ const codeInput = this.$refs.codeInput
+ codeInput.focus()
+ codeInput.setSelectionRange(0, codeInput.value.length)
+ },
+
submit () {
- const { clientId, clientSecret } = this.oauth
+ const { clientId, clientSecret } = this.oauthStore
const data = {
clientId,
clientSecret,
instance: this.instance.server,
mfaToken: this.authSettings.mfa_token,
code: this.code
}
mfaApi.verifyRecoveryCode(data).then((result) => {
if (result.error) {
this.error = result.error
this.code = null
+ this.focusOnCodeInput()
return
}
this.login(result).then(() => {
this.$router.push({ name: 'friends' })
})
})
}
}
}
diff --git a/src/components/mfa_form/recovery_form.vue b/src/components/mfa_form/recovery_form.vue
index f8c3e6a048..02f27ddaf9 100644
--- a/src/components/mfa_form/recovery_form.vue
+++ b/src/components/mfa_form/recovery_form.vue
@@ -1,74 +1,76 @@
<template>
- <div class="login panel panel-default">
+ <div class="login-panel panel panel-default">
<!-- Default panel contents -->
<div class="panel-heading">
<h1 class="title">
{{ $t('login.heading.recovery') }}
</h1>
</div>
<div class="panel-body">
<form
class="login-form"
@submit.prevent="submit"
>
<div class="form-group">
<label for="code">{{ $t('login.recovery_code') }}</label>
<input
id="code"
+ ref="codeInput"
v-model="code"
class="input form-control"
>
</div>
<div class="form-group">
<div class="login-bottom">
<div>
<button
class="button-unstyled -link"
type="button"
@click.prevent="requireTOTP"
>
{{ $t('login.enter_two_factor_code') }}
</button>
<br>
<button
class="button-unstyled -link"
type="button"
@click.prevent="abortMFA"
>
{{ $t('general.cancel') }}
</button>
</div>
<button
type="submit"
class="btn button-default"
>
{{ $t('general.verify') }}
</button>
</div>
</div>
</form>
</div>
<div
v-if="error"
class="form-group"
>
<div class="alert error">
{{ error }}
<button
class="button-unstyled"
@click="clearError"
>
<FAIcon
class="fa-scale-110 fa-old-padding"
icon="times"
/>
</button>
</div>
</div>
</div>
</template>
+
<script src="./recovery_form.js"></script>
diff --git a/src/components/mfa_form/totp_form.js b/src/components/mfa_form/totp_form.js
index 6ee823ed37..857d055ff1 100644
--- a/src/components/mfa_form/totp_form.js
+++ b/src/components/mfa_form/totp_form.js
@@ -1,54 +1,64 @@
import mfaApi from '../../services/new_api/mfa.js'
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 {
faTimes
} from '@fortawesome/free-solid-svg-icons'
library.add(
faTimes
)
export default {
data: () => ({
code: null,
error: false
}),
computed: {
...mapGetters({
authSettings: 'authFlow/settings'
}),
+ ...mapStores(useOAuthStore),
...mapState({
instance: 'instance',
- oauth: 'oauth'
})
},
methods: {
...mapMutations('authFlow', ['requireRecovery', 'abortMFA']),
...mapActions({ login: 'authFlow/login' }),
clearError () { this.error = false },
+
+ focusOnCodeInput () {
+ const codeInput = this.$refs.codeInput
+ codeInput.focus()
+ codeInput.setSelectionRange(0, codeInput.value.length)
+ },
+
submit () {
- const { clientId, clientSecret } = this.oauth
+ const { clientId, clientSecret } = this.oauthStore
const data = {
clientId,
clientSecret,
instance: this.instance.server,
mfaToken: this.authSettings.mfa_token,
code: this.code
}
mfaApi.verifyOTPCode(data).then((result) => {
if (result.error) {
this.error = result.error
this.code = null
+ this.focusOnCodeInput()
return
}
this.login(result).then(() => {
this.$router.push({ name: 'friends' })
})
})
}
}
}
diff --git a/src/components/mfa_form/totp_form.vue b/src/components/mfa_form/totp_form.vue
index 26fc1e8044..b057f0413d 100644
--- a/src/components/mfa_form/totp_form.vue
+++ b/src/components/mfa_form/totp_form.vue
@@ -1,77 +1,79 @@
<template>
- <div class="login panel panel-default">
+ <div class="login-panel panel panel-default">
<!-- Default panel contents -->
<div class="panel-heading">
<h1 class="title">
{{ $t('login.heading.totp') }}
</h1>
</div>
<div class="panel-body">
<form
class="login-form"
@submit.prevent="submit"
>
<div class="form-group">
<label for="code">
{{ $t('login.authentication_code') }}
</label>
<input
id="code"
+ ref="codeInput"
v-model="code"
class="input form-control"
>
</div>
<div class="form-group">
<div class="login-bottom">
<div>
<button
class="button-unstyled -link"
type="button"
@click.prevent="requireRecovery"
>
{{ $t('login.enter_recovery_code') }}
</button>
<br>
<button
class="button-unstyled -link"
type="button"
@click.prevent="abortMFA"
>
{{ $t('general.cancel') }}
</button>
</div>
<button
type="submit"
class="btn button-default"
>
{{ $t('general.verify') }}
</button>
</div>
</div>
</form>
</div>
<div
v-if="error"
class="form-group"
>
<div class="alert error">
{{ error }}
<button
class="button-unstyled"
@click="clearError"
>
<FAIcon
size="lg"
class="fa-scale-110 fa-old-padding"
icon="times"
/>
</button>
</div>
</div>
</div>
</template>
+
<script src="./totp_form.js"></script>

File Metadata

Mime Type
text/x-diff
Expires
Fri, Oct 30, 12:13 AM (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1798955
Default Alt Text
(8 KB)

Event Timeline