Merge pull request #442 from n8henrie/master

Add test for valid username
This commit is contained in:
Nick Farina
2015-12-28 09:33:08 -08:00

View File

@@ -124,6 +124,15 @@ Server.prototype._loadConfig = function() {
throw err;
}
var accessoryCount = (config.accessories && config.accessories.length) || 0;
var username = config.bridge.username;
var validMac = /^([0-9A-F]{2}:){5}([0-9A-F]{2})$/;
if (!validMac.test(username)){
throw new Error('Not a valid username: ' + username + '. Must be 6 pairs of colon-' +
'separated hexadecimal chars (A-F 0-9), like a MAC address.');
}
var accessoryCount = (config.accessories && config.accessories.length) || 0;
var platformCount = (config.platforms && config.platforms.length) || 0;
log.info("Loaded config.json with %s accessories and %s platforms.", accessoryCount, platformCount);