Skip to content

Commit

Permalink
manage the tokens on device side
Browse files Browse the repository at this point in the history
  • Loading branch information
lluis-protofy-xyz committed Oct 31, 2024
1 parent b25a9f2 commit c694abb
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,20 @@ export class DevicesModel extends ProtoModel<DevicesModel> {
console.log(response1.error)
return;
}
const res = await API.get("/api/core/v1/tokens/device/create?deviceId=" + this.data.name)
if (res.isError) {
console.log(res.error)
}
console.log("---------deviceDefinition----------", deviceDefinition)
deviceDefinition.board = response1.data
const jsCode = deviceDefinition.config.components;

const deviceCode = 'device(' + jsCode.replace(/;/g, "") + ')';
console.log("-------DEVICE CODE------------", deviceCode)
const deviceObj = eval(deviceCode)
if(res.data.token){
deviceObj.setCredentials({mqtt: {username: this.data.name, password: res.data.token}})
}
const componentsTree = deviceObj.getComponentsTree(this.data.name, deviceDefinition)
yaml = deviceObj.dump("yaml").replace(/'@/g,"").replace(/@'/g,"")

Expand Down

0 comments on commit c694abb

Please sign in to comment.