You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.4 KiB
56 lines
1.4 KiB
// admin/otp.js
|
|
// Copyright (C) 2021 Digital Telepresence, LLC
|
|
// License: Apache-2.0
|
|
|
|
'use strict';
|
|
|
|
const express = require('express');
|
|
// const multer = require('multer');
|
|
|
|
const { SiteController, SiteError } = require('../../../lib/site-lib');
|
|
|
|
class OtpAdminController extends SiteController {
|
|
|
|
constructor (dtp) {
|
|
super(dtp, module.exports);
|
|
}
|
|
|
|
async start ( ) {
|
|
// const upload = multer({ dest: `/tmp/${this.dtp.config.site.domainKey}/uploads/${this.component.logId}` });
|
|
|
|
const router = express.Router();
|
|
router.use(async (req, res, next) => {
|
|
res.locals.currentView = 'admin';
|
|
res.locals.adminView = 'otp';
|
|
return next();
|
|
});
|
|
|
|
// router.param('otp', this.populateOtp.bind(this));
|
|
|
|
router.get('/', this.getIndex.bind(this));
|
|
|
|
return router;
|
|
}
|
|
|
|
async getIndex (req, res, next) {
|
|
try {
|
|
const { otpAuth: otpAuthService } = this.dtp.services;
|
|
if (!req.user) {
|
|
throw new SiteError(402, "Error getting user");
|
|
}
|
|
res.locals.tokens = await otpAuthService.getBackupTokens(req.user, "Admin");
|
|
res.render('admin/otp/index');
|
|
} catch (error) {
|
|
this.log.error('failed to get tokens', { error });
|
|
return next(error);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = {
|
|
logId: 'admin-otp',
|
|
index: 'adminOtp',
|
|
className: 'OtpAdminController',
|
|
create: async (dtp) => { return new OtpAdminController(dtp); },
|
|
};
|