+ updateKeys worker
parent
4b9bdd3bda
commit
cbccdb2e69
|
@ -3,7 +3,7 @@
|
|||
|
||||
# get_auth_string()
|
||||
function get_auth_string() {
|
||||
if ! session_verify ${cookies[sh_session]}; then
|
||||
if ! session_verify "${cookies[sh_session]}"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
@ -11,7 +11,7 @@ function get_auth_string() {
|
|||
}
|
||||
|
||||
function get_refresh_token() {
|
||||
if ! session_verify ${cookies[sh_session]}; then
|
||||
if ! session_verify "${cookies[sh_session]}"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
@ -20,41 +20,42 @@ function get_refresh_token() {
|
|||
|
||||
# check_if_user_exists(file)
|
||||
function check_if_user_exists() {
|
||||
if ! session_verify ${cookies[sh_session]}; then
|
||||
if ! session_verify "${cookies[sh_session]}"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ $1 == "refreshToken" ]]; then
|
||||
if [[ $(cat secret/refreshTokens.dat | grep "${cookies[sh_session]}:") != "" ]]; then
|
||||
return 1
|
||||
fi
|
||||
elif [[ $1 == "authToken" ]]; then
|
||||
if [[ $(cat secret/authTokens.dat | grep "${cookies[sh_session]}:") != "" ]]; then
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
[[ $1 == "refreshToken" ]] && [[ $(cat secret/refreshTokens.dat | grep "${cookies[sh_session]}:") != "" ]] && return 1
|
||||
[[ $1 == "authToken" ]] && [[ $(cat secret/authTokens.dat | grep "${cookies[sh_session]}:") != "" ]] && return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
# add_account_refreshtoken(refreshtoken)
|
||||
function add_account_refreshtoken() {
|
||||
if ! session_verify ${cookies[sh_session]}; then
|
||||
if ! session_verify "${cookies[sh_session]}"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if check_if_user_exists refreshToken; then
|
||||
echo ${cookies[sh_session]}:$1 >> secret/refreshTokens.dat
|
||||
echo "$(session_get_username ${cookies[sh_session]}):$1" >> secret/refreshTokens.dat
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# add_account_authtoken(authtoken)
|
||||
function add_account_authtoken() {
|
||||
if ! session_verify ${cookies[sh_session]}; then
|
||||
if ! session_verify "${cookies[sh_session]}"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if check_if_user_exists authToken; then
|
||||
echo ${cookies[sh_session]}:$1 >> secret/authTokens.dat
|
||||
echo "$(session_get_username ${cookies[sh_session]}):$1" >> secret/authTokens.dat
|
||||
fi
|
||||
}
|
||||
|
||||
# update_account_authtoken(username)
|
||||
function update_account_authtoken() {
|
||||
a=$(cat secret/refreshTokens.dat | grep -P "^$1\:")
|
||||
token=$(awk -F: '{print $2}' <<< $a);
|
||||
auth=$(curl -s -X POST -H "Content-type: application/json" --data '{"phoneOS": "Android", "refreshToken": "'"$token"'"}' https://api-inmobile-pl.easypack24.net/v1/authenticate | jq -r .authToken | sed -s 's/Bearer //g')
|
||||
sed -E -i 's/^'"$1"':.*/'"$1:$auth"'/g' secret/authTokens.dat
|
||||
}
|
||||
|
|
|
@ -1,2 +1,8 @@
|
|||
#!/bin/bash
|
||||
date
|
||||
pwd > pwd
|
||||
source ${cfg[namespace]}/code/common.sh
|
||||
|
||||
for i in $(cat secret/refreshTokens.dat); do
|
||||
name=$(awk -F: '{print $1}'<<< $i)
|
||||
update_account_authtoken "$name"
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue