diff --git a/src/commands/auth/login.sh b/src/commands/auth/login.sh index b631469..dec8ca1 100644 --- a/src/commands/auth/login.sh +++ b/src/commands/auth/login.sh @@ -2,6 +2,8 @@ wx-login(){ if [[ ! -z $1 ]] then ORG=$1 + jq '.org = "'$ORG'"' $HOME/.warengroup/config.json 1> $HOME/.warengroup/config.json.tmp + mv $HOME/.warengroup/config.json.tmp $HOME/.warengroup/config.json &> /dev/null elif [[ $(hostname -d) = *"devices.waren.io" ]] then ORG=warengroup @@ -11,6 +13,9 @@ wx-login(){ elif [[ $(hostname -d) = *"devices.christerwaren.fi" ]] then ORG=cwchristerw + elif [[ $USER != "root" && $USER != "local" && -f "$HOME/.warengroup/config.json" && $(cat $HOME/.warengroup/config.json | jq -r .org) ]] + then + ORG=$(cat $HOME/.warengroup/config.json | jq -r .org) else wx-header "Login" echo "Status: Organization Required" diff --git a/wx b/wx index 055956e..d0bbe1a 100755 --- a/wx +++ b/wx @@ -232,6 +232,8 @@ wx-login(){ if [[ ! -z $1 ]] then ORG=$1 + jq '.org = "'$ORG'"' $HOME/.warengroup/config.json 1> $HOME/.warengroup/config.json.tmp + mv $HOME/.warengroup/config.json.tmp $HOME/.warengroup/config.json &> /dev/null elif [[ $(hostname -d) = *"devices.waren.io" ]] then ORG=warengroup @@ -241,6 +243,9 @@ wx-login(){ elif [[ $(hostname -d) = *"devices.christerwaren.fi" ]] then ORG=cwchristerw + elif [[ $USER != "root" && $USER != "local" && -f "$HOME/.warengroup/config.json" && $(cat $HOME/.warengroup/config.json | jq -r .org) ]] + then + ORG=$(cat $HOME/.warengroup/config.json | jq -r .org) else wx-header "Login" echo "Status: Organization Required"