4 changed files with 79 additions and 0 deletions
@ -0,0 +1,59 @@ |
|||||
|
// 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/${module.exports.slug}` });
|
||||
|
|
||||
|
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)); |
||||
|
|
||||
|
// router.delete('/:postId', this.deletePost.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 = { |
||||
|
name: 'adminOtp', |
||||
|
slug: 'admin-opt', |
||||
|
create: async (dtp) => { return new OtpAdminController(dtp); }, |
||||
|
}; |
@ -0,0 +1,12 @@ |
|||||
|
extends ../layouts/main |
||||
|
block content |
||||
|
|
||||
|
div(uk-grid) |
||||
|
.uk-width-expand |
||||
|
h1 Tokens |
||||
|
.uk-card-body |
||||
|
h3 These tokens should be saved in a safe place so you can get into your account should you lose your 2FA device |
||||
|
each token of tokens |
||||
|
ul.uk-list.uk-list-divider |
||||
|
li |
||||
|
.uk-text-small= token.token |
Loading…
Reference in new issue