Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85948974
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/components/settings_modal/tabs/security_tab/mfa.js b/src/components/settings_modal/tabs/security_tab/mfa.js
index 7eb32b122f..fa0979b0c7 100644
--- a/src/components/settings_modal/tabs/security_tab/mfa.js
+++ b/src/components/settings_modal/tabs/security_tab/mfa.js
@@ -1,178 +1,178 @@
import VueQrcode from '@chenfengyuan/vue-qrcode'
import Confirm from './confirm.vue'
import RecoveryCodes from './mfa_backup_codes.vue'
import TOTP from './mfa_totp.vue'
import { useOAuthStore } from 'src/stores/oauth.js'
import {
generateMfaBackupCodes,
mfaConfirmOTP,
mfaSetupOTP,
settingsMFA,
} from 'src/api/user.js'
const Mfa = {
data: () => ({
settings: {
// current settings of MFA
available: false,
enabled: false,
totp: false,
},
setupState: {
// setup mfa
state: '', // state of setup. '' -> 'getBackupCodes' -> 'setupOTP' -> 'complete'
setupOTPState: '', // state of setup otp. '' -> 'prepare' -> 'confirm' -> 'complete'
},
backupCodes: {
getNewCodes: false,
inProgress: false, // progress of fetch codes
codes: [],
},
otpSettings: {
// pre-setup setting of OTP. secret key, qrcode url.
provisioning_uri: '',
key: '',
},
currentPassword: null,
otpConfirmToken: null,
error: null,
readyInit: false,
}),
components: {
RecoveryCodes,
- 'TOTPItem': TOTP,
+ TOTPItem: TOTP,
qrcode: VueQrcode,
confirm: Confirm,
},
computed: {
canSetupOTP() {
return (
((this.setupInProgress && this.backupCodesPrepared) ||
this.settings.enabled) &&
!this.settings.totp &&
!this.setupOTPInProgress
)
},
setupInProgress() {
return (
this.setupState.state !== '' && this.setupState.state !== 'complete'
)
},
setupOTPInProgress() {
return this.setupState.state === 'setupOTP' && !this.completedOTP
},
prepareOTP() {
return this.setupState.setupOTPState === 'prepare'
},
confirmOTP() {
return this.setupState.setupOTPState === 'confirm'
},
completedOTP() {
return this.setupState.setupOTPState === 'completed'
},
backupCodesPrepared() {
return !this.backupCodes.inProgress && this.backupCodes.codes.length > 0
},
confirmNewBackupCodes() {
return this.backupCodes.getNewCodes
},
},
methods: {
activateOTP() {
if (!this.settings.enabled) {
this.setupState.state = 'getBackupcodes'
this.fetchBackupCodes()
}
},
fetchBackupCodes() {
this.backupCodes.inProgress = true
this.backupCodes.codes = []
return generateMfaBackupCodes({
credentials: useOAuthStore().token,
}).then(({ data: res }) => {
this.backupCodes.codes = res.codes
this.backupCodes.inProgress = false
})
},
getBackupCodes() {
// get a new backup codes
this.backupCodes.getNewCodes = true
},
confirmBackupCodes() {
// confirm getting new backup codes
this.fetchBackupCodes().then(() => {
this.backupCodes.getNewCodes = false
})
},
cancelBackupCodes() {
// cancel confirm form of new backup codes
this.backupCodes.getNewCodes = false
},
// Setup OTP
setupOTP() {
// prepare setup OTP
this.setupState.state = 'setupOTP'
this.setupState.setupOTPState = 'prepare'
mfaSetupOTP({
credentials: useOAuthStore().token,
}).then(({ data: res }) => {
this.otpSettings = res
this.setupState.setupOTPState = 'confirm'
})
},
doConfirmOTP() {
// handler confirm enable OTP
this.error = null
mfaConfirmOTP({
token: this.otpConfirmToken,
password: this.currentPassword,
credentials: useOAuthStore().token,
})
.then(() => {
this.completeSetup()
})
.catch((error) => {
this.error = error
})
},
completeSetup() {
this.setupState.setupOTPState = 'complete'
this.setupState.state = 'complete'
this.currentPassword = null
this.error = null
this.fetchSettings()
},
cancelSetup() {
// cancel setup
this.setupState.setupOTPState = ''
this.setupState.state = ''
this.currentPassword = null
this.error = null
},
// end Setup OTP
// fetch settings from server
async fetchSettings() {
const { data: result } = await settingsMFA({
credentials: useOAuthStore().token,
})
if (result.error) return
this.settings = result.settings
this.settings.available = true
return result
},
},
mounted() {
this.fetchSettings().then(() => {
this.readyInit = true
})
},
}
export default Mfa
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Nov 17, 4:22 PM (11 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1839653
Default Alt Text
(4 KB)
Attached To
Mode
rPUFE pleroma-fe-upstream
Attached
Detach File
Event Timeline