30 lines
899 B
JavaScript
30 lines
899 B
JavaScript
|
|
const express = require('express');
|
||
|
|
const router = express.Router();
|
||
|
|
const domainValidator = require('../validators/domain');
|
||
|
|
const authMw = require('../session');
|
||
|
|
const database = require('../database.js');
|
||
|
|
const dbConnection = database.db;
|
||
|
|
const Sequelize = require('sequelize');
|
||
|
|
const pageTitle = 'Domain Manager | Edit DNS';
|
||
|
|
|
||
|
|
|
||
|
|
// Manage domains
|
||
|
|
router.get('/dns/edit/:domainId', authMw.AllowIfAuthenticated, async (req, res, next) => {
|
||
|
|
const result = await dbConnection.transaction(async(t) => {
|
||
|
|
const ownedDomain = await database.models.RegisteredDomain.findOne({
|
||
|
|
where: {
|
||
|
|
id: req.params.domainId,
|
||
|
|
owner: req.session.userId
|
||
|
|
}
|
||
|
|
}, {transaction: t});
|
||
|
|
|
||
|
|
return ownedDomain;
|
||
|
|
});
|
||
|
|
|
||
|
|
if(!result)
|
||
|
|
return next();
|
||
|
|
|
||
|
|
res.render('dns', {title: pageTitle, domain: result});
|
||
|
|
});
|
||
|
|
|
||
|
|
module.exports = router;
|