Add MFA support
This commit is contained in:
16
app/assets/app/service/Action.service.js
Normal file
16
app/assets/app/service/Action.service.js
Normal 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 }
|
||||
@@ -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()
|
||||
|
||||
@@ -7,6 +7,10 @@ class LocationService {
|
||||
}, delay)
|
||||
})
|
||||
}
|
||||
|
||||
async back() {
|
||||
return window.history.back()
|
||||
}
|
||||
}
|
||||
|
||||
const location_service = new LocationService()
|
||||
|
||||
Reference in New Issue
Block a user