Add MFA support

This commit is contained in:
garrettmills
2020-04-22 16:56:39 -05:00
parent d68d5141c8
commit e3ecfb0d37
30 changed files with 802 additions and 75 deletions

View File

@@ -0,0 +1,16 @@
import { location_service } from './Location.service.js'
class ActionService {
async perform({ text, action, ...args }) {
if ( action === 'redirect' ) {
if ( args.next ) {
return location_service.redirect(args.next, 1500)
}
} else {
throw new TypeError(`Unknown action type: ${action}`)
}
}
}
const action_service = new ActionService()
export { action_service }

View File

@@ -17,6 +17,21 @@ class AuthAPI {
return { success: false }
}
async mfa_generate() {
const result = await axios.post('/api/v1/auth/mfa/generate')
return result && result.data && result.data.data
}
async mfa_attempt(verify_code) {
const result = await axios.post('/api/v1/auth/mfa/attempt', { verify_code })
return result && result.data && result.data.data
}
async mfa_enable() {
const result = await axios.post('/api/v1/auth/mfa/enable')
return result && result.data && result.data.data && result.data.data.success && result.data.data.mfa_enabled
}
}
const auth_api = new AuthAPI()

View File

@@ -7,6 +7,10 @@ class LocationService {
}, delay)
})
}
async back() {
return window.history.back()
}
}
const location_service = new LocationService()