Skip to content

Commit

Permalink
JS API - Change auth header for ApiKEY
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardojlrufino committed Aug 5, 2018
1 parent 1794d7a commit 3339217
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
13 changes: 9 additions & 4 deletions opendevice-clients/opendevice-js/dist/js/opendevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ od.DeviceType = {
BOARD:10,
MANAGER:11,

isNumeric : function(type){
isAnalog : function(type){
return type == od.DeviceType.ANALOG
|| type == od.DeviceType.FLOAT2
|| type == od.DeviceType.FLOAT4
Expand Down Expand Up @@ -129,7 +129,7 @@ od.CommandStatus = {
od.Event = {
DEVICE_LIST_UPDATE : "devicesUpdate",
DEVICE_CHANGED : "deviceChanged",
CONNECTION_CHANGE : "connectionCgange",
CONNECTION_CHANGE : "connectionChange",
CONNECTED : "connected",
DISCONNECTED : "disconnected",
LOGIN_FAILURE : "loginFail"
Expand Down Expand Up @@ -197,6 +197,7 @@ od.Device = function(data){
}
});
};

function notifyListeners(){

}
Expand Down Expand Up @@ -258,7 +259,7 @@ od.Device = function(data){

/**
* Register a listener to monitor changes in this Device.
* @param {function} listener
* @param {function} listener - Receive params VALUE, ID
* @param {Object} [context] - Context to execute listener
* @returns {{context: *, listener: *}} - return registred listener (used in #removeListener)
*/
Expand Down Expand Up @@ -1152,6 +1153,10 @@ return {
od.appID = appID;
},

setApyKey : function(appID){
od.appID = appID;
},

setServer : function(serverURL){
od.serverURL = serverURL;
},
Expand All @@ -1168,7 +1173,7 @@ return {
type: "GET",
url: od.serverURL + path,
headers : {
'Authorization' : "Bearer " + od.appID
'Authorization' : "ApiKey " + od.appID
},
async: false // FIXME: isso não é recomendado...
};
Expand Down
10 changes: 5 additions & 5 deletions opendevice-clients/opendevice-js/dist/js/opendevice.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions opendevice-clients/opendevice-js/src/js/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ od.DeviceType = {
BOARD:10,
MANAGER:11,

isNumeric : function(type){
isAnalog : function(type){
return type == od.DeviceType.ANALOG
|| type == od.DeviceType.FLOAT2
|| type == od.DeviceType.FLOAT4
Expand Down Expand Up @@ -129,7 +129,7 @@ od.CommandStatus = {
od.Event = {
DEVICE_LIST_UPDATE : "devicesUpdate",
DEVICE_CHANGED : "deviceChanged",
CONNECTION_CHANGE : "connectionCgange",
CONNECTION_CHANGE : "connectionChange",
CONNECTED : "connected",
DISCONNECTED : "disconnected",
LOGIN_FAILURE : "loginFail"
Expand Down
3 changes: 2 additions & 1 deletion opendevice-clients/opendevice-js/src/js/Device.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ od.Device = function(data){
}
});
};

function notifyListeners(){

}
Expand Down Expand Up @@ -123,7 +124,7 @@ od.Device = function(data){

/**
* Register a listener to monitor changes in this Device.
* @param {function} listener
* @param {function} listener - Receive params VALUE, ID
* @param {Object} [context] - Context to execute listener
* @returns {{context: *, listener: *}} - return registred listener (used in #removeListener)
*/
Expand Down
6 changes: 5 additions & 1 deletion opendevice-clients/opendevice-js/src/js/OpenDeviceJS.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ return {
od.appID = appID;
},

setApyKey : function(appID){
od.appID = appID;
},

setServer : function(serverURL){
od.serverURL = serverURL;
},
Expand All @@ -77,7 +81,7 @@ return {
type: "GET",
url: od.serverURL + path,
headers : {
'Authorization' : "Bearer " + od.appID
'Authorization' : "ApiKey " + od.appID
},
async: false // FIXME: isso não é recomendado...
};
Expand Down

0 comments on commit 3339217

Please sign in to comment.