Skip to content

Commit 0ad5455

Browse files
committed
test: added accountTemplate for registering hostname at app creation time
1 parent 07ee53c commit 0ad5455

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/create-app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const corsProxy = require('./handlers/cors-proxy')
1111
const authProxy = require('./handlers/auth-proxy')
1212
const SolidHost = require('./models/solid-host')
1313
const AccountManager = require('./models/account-manager')
14+
const AccountTemplate = require('./models/account-template')
1415
const vhost = require('vhost')
1516
const EmailService = require('./services/email-service')
1617
const TokenService = require('./services/token-service')
@@ -52,6 +53,8 @@ function createApp (argv = {}) {
5253
defaultContentType: argv.defaultContentType
5354
})
5455

56+
AccountTemplate.registerHostname(argv.serverUri)
57+
5558
const configPath = config.initConfigDir(argv)
5659
argv.templates = config.initTemplateDirs(configPath)
5760

lib/models/account-template.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ class AccountTemplate {
3535
this.templateFiles = options.templateFiles || TEMPLATE_FILES
3636
}
3737

38+
/**
39+
* Registers the server hostname at compile time to check for webID stuff.
40+
* @param {string} hostname
41+
* @throws if hostname already registered
42+
*/
43+
static registerHostname (hostname) {
44+
if (this.hostname) {
45+
throw new Error('hostname already registered')
46+
} else {
47+
this.hostname = hostname
48+
}
49+
}
50+
3851
/**
3952
* Factory method, returns an AccountTemplate for a given user account.
4053
*

0 commit comments

Comments
 (0)