Skip to content

Commit

Permalink
Add logic to force 2FA PIN on GHome-enabled user new lock device defi…
Browse files Browse the repository at this point in the history
…nition
  • Loading branch information
coldfire84 committed Jan 24, 2020
1 parent 10d895d commit 30ae1a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/routes/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,13 @@ router.put('/devices', defaultLimiter,
var device = req.body;
// Set username on device to match req.user.username
device.username = user;

// Sanity check new device
if (req.user.activeServices.indexOf('Google') > -1 && device.displayCategories == 'SMARTLOCK' && (!device.attributes.require2FA || !device.attributes.pin || !device.attributes.type2FA)){
logger.log('warning' , "[Create Device] Google Home user tried to create new Smart Lock device without a PIN");
res.status(500).send('As a Google Home user you must set a PIN on your lock!');
}

// Create new device
var dev = new Devices(device);
// Save device
Expand Down
1 change: 1 addition & 0 deletions src/routes/ghome.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ router.post('/action', defaultLimiter,
}
// FanSpeed, map 1:1 with RangeController 1-10
if (device.capabilities.indexOf("RangeController") > -1 && (dev.type.indexOf('action.devices.types.FAN') > -1 || dev.type.indexOf('action.devices.types.THERMOSTAT') > -1 )){
//dev.supportsFanSpeedPercent = true;
dev.attributes.availableFanSpeeds = {
"availableFanSpeeds": {
"speeds": [{
Expand Down

0 comments on commit 30ae1a6

Please sign in to comment.