Merge PR #34 from adn77/master

Changed customerId retrieval
This commit is contained in:
Alex
2019-01-23 01:01:47 +01:00
committato da GitHub
2 ha cambiato i file con 22 aggiunte e 13 eliminazioni

Vedi File

@@ -445,7 +445,9 @@ check_status()
# bootstrap with GUI-Version writes GUI version to cookie
# returns among other the current authentication state
#
AUTHSTATUS=$(${CURL} ${OPTS} -s -b ${COOKIE} -A "${BROWSER}" -H "DNT: 1" -H "Connection: keep-alive" -L https://${ALEXA}/api/bootstrap?version=${GUIVERSION} | sed -r 's/^.*"authenticated":([^,]+),.*$/\1/g')
AUTHSTATUS=$(${CURL} ${OPTS} -s -b ${COOKIE} -A "${BROWSER}" -H "DNT: 1" -H "Connection: keep-alive" -L https://${ALEXA}/api/bootstrap?version=${GUIVERSION})
MEDIAOWNERCUSTOMERID=$(echo $AUTHSTATUS | sed -r 's/^.*"customerId":"([^,]+)",.*$/\1/g')
AUTHSTATUS=$(echo $AUTHSTATUS | sed -r 's/^.*"authenticated":([^,]+),.*$/\1/g')
if [ "$AUTHSTATUS" = "true" ] ; then
return 1
@@ -470,7 +472,10 @@ set_var()
DEVICETYPE=$(jq --arg device "${DEVICE}" -r '.devices[] | select(.accountName == $device) | .deviceType' ${DEVLIST})
DEVICESERIALNUMBER=$(jq --arg device "${DEVICE}" -r '.devices[] | select(.accountName == $device) | .serialNumber' ${DEVLIST})
MEDIAOWNERCUSTOMERID=$(jq --arg device "${DEVICE}" -r '.devices[] | select(.accountName == $device) | .deviceOwnerCustomerId' ${DEVLIST})
# customerId is now retrieved from the logged in user
# the customerId in the device list is always from the user registering the device initially
# MEDIAOWNERCUSTOMERID=$(jq --arg device "${DEVICE}" -r '.devices[] | select(.accountName == $device) | .deviceOwnerCustomerId' ${DEVLIST})
if [ -z "${DEVICESERIALNUMBER}" ] ; then
echo "ERROR: unkown device dev:${DEVICE}"

Vedi File

@@ -396,7 +396,9 @@ check_status()
# bootstrap with GUI-Version writes GUI version to cookie
# returns among other the current authentication state
#
AUTHSTATUS=$(${CURL} ${OPTS} -s -b ${COOKIE} -A "${BROWSER}" -H "DNT: 1" -H "Connection: keep-alive" -L https://${ALEXA}/api/bootstrap?version=${GUIVERSION} | sed -r 's/^.*"authenticated":([^,]+),.*$/\1/g')
AUTHSTATUS=$(${CURL} ${OPTS} -s -b ${COOKIE} -A "${BROWSER}" -H "DNT: 1" -H "Connection: keep-alive" -L https://${ALEXA}/api/bootstrap?version=${GUIVERSION})
MEDIAOWNERCUSTOMERID=$(echo $AUTHSTATUS | sed -r 's/^.*"customerId":"([^,]+)",.*$/\1/g')
AUTHSTATUS=$(echo $AUTHSTATUS | sed -r 's/^.*"authenticated":([^,]+),.*$/\1/g')
if [ "$AUTHSTATUS" = "true" ] ; then
return 1
@@ -419,8 +421,8 @@ set_var()
ATTR="serialNumber"
SERIAL=`grep ${ATTR}\| ${DEVTXT} | sed "s/^.*${ATTR}|//" | sed 's/ /_/g'`
ATTR="deviceOwnerCustomerId"
MEDIAID=`grep ${ATTR}\| ${DEVTXT} | sed "s/^.*${ATTR}|//" | sed 's/ /_/g'`
# ATTR="deviceOwnerCustomerId"
# MEDIAID=`grep ${ATTR}\| ${DEVTXT} | sed "s/^.*${ATTR}|//" | sed 's/ /_/g'`
ATTR="deviceFamily"
FAMILY=`grep ${ATTR}\| ${DEVTXT} | sed "s/^.*${ATTR}|//" | sed 's/ /_/g'`
@@ -457,14 +459,16 @@ set_var()
done
fi
C=0
for I in $MEDIAID ; do
if [ $C -eq $IDX ] ; then
MEDIAOWNERCUSTOMERID=$I
break
fi
C=$((C+1))
done
# customerId is now retrieved from the logged in user
# the customerId in the device list is always from the user registering the device initially
# C=0
# for I in $MEDIAID ; do
# if [ $C -eq $IDX ] ; then
# MEDIAOWNERCUSTOMERID=$I
# break
# fi
# C=$((C+1))
# done
C=0
for I in $TYPE ; do