43 lines
827 B
TypeScript
43 lines
827 B
TypeScript
import AbstractService from './abstractService'
|
|
import TotpModel from '@/models/totp'
|
|
import type {ITotp} from '@/modelTypes/ITotp'
|
|
|
|
const urlPrefix = '/user/settings/totp' as const
|
|
type Paths = {
|
|
get: typeof urlPrefix
|
|
}
|
|
|
|
export default class TotpService extends AbstractService<ITotp, Paths> {
|
|
urlPrefix = urlPrefix
|
|
|
|
constructor() {
|
|
super({
|
|
get: urlPrefix,
|
|
})
|
|
}
|
|
|
|
modelFactory(data) {
|
|
return new TotpModel(data)
|
|
}
|
|
|
|
enroll() {
|
|
return this.post(`${this.urlPrefix}/enroll`, {})
|
|
}
|
|
|
|
enable(model) {
|
|
return this.post(`${this.urlPrefix}/enable`, model)
|
|
}
|
|
|
|
disable(model) {
|
|
return this.post(`${this.urlPrefix}/disable`, model)
|
|
}
|
|
|
|
async qrcode() {
|
|
const response = await this.http({
|
|
url: `${this.urlPrefix}/qrcode`,
|
|
method: 'GET',
|
|
responseType: 'blob',
|
|
})
|
|
return new Blob([response.data])
|
|
}
|
|
} |