most variables are local now, fix bug
This commit is contained in:
parent
85d0fdfcc8
commit
d99a160bc0
|
@ -7,7 +7,7 @@ function get_auth_string() {
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
user="$(session_get_username ${cookies[sh_session]})"
|
local user="$(session_get_username ${cookies[sh_session]})"
|
||||||
|
|
||||||
echo "Authorization: Bearer $(cat secret/authTokens.dat | grep -P "^$user:" | sed -s "s/$user://")"
|
echo "Authorization: Bearer $(cat secret/authTokens.dat | grep -P "^$user:" | sed -s "s/$user://")"
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ function get_refresh_token() {
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
user="$(session_get_username ${cookies[sh_session]})"
|
local user="$(session_get_username ${cookies[sh_session]})"
|
||||||
|
|
||||||
echo "$(cat secret/refreshTokens.dat | grep -P "^$user:" | sed -s "s/$user://")"
|
echo "$(cat secret/refreshTokens.dat | grep -P "^$user:" | sed -s "s/$user://")"
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ function check_if_user_exists() {
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
user=$(session_get_username ${cookies[sh_session]})
|
local user=$(session_get_username ${cookies[sh_session]})
|
||||||
|
|
||||||
[[ $1 == "refreshToken" ]] && [[ $(cat secret/refreshTokens.dat | grep -P "^$user:") != "" ]] && return 1
|
[[ $1 == "refreshToken" ]] && [[ $(cat secret/refreshTokens.dat | grep -P "^$user:") != "" ]] && return 1
|
||||||
[[ $1 == "authToken" ]] && [[ $(cat secret/authTokens.dat | grep -P "^$user:") != "" ]] && return 1
|
[[ $1 == "authToken" ]] && [[ $(cat secret/authTokens.dat | grep -P "^$user:") != "" ]] && return 1
|
||||||
|
@ -60,8 +60,9 @@ function add_account_authtoken() {
|
||||||
|
|
||||||
# update_account_authtoken(username)
|
# update_account_authtoken(username)
|
||||||
function update_account_authtoken() {
|
function update_account_authtoken() {
|
||||||
a=$(cat secret/refreshTokens.dat | grep -P "^$1\:")
|
local a=$(cat secret/refreshTokens.dat | grep -P "^$1\:")
|
||||||
token=$(awk -F: '{print $2}' <<< $a);
|
local token=$(awk -F: '{print $2}' <<< $a);
|
||||||
|
local auth=''
|
||||||
while true; do
|
while true; do
|
||||||
if [[ "$auth" == '' ]]; then
|
if [[ "$auth" == '' ]]; then
|
||||||
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')
|
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')
|
||||||
|
@ -104,15 +105,15 @@ function account_gen_reset_code() {
|
||||||
[[ "$1" == '' ]] && return
|
[[ "$1" == '' ]] && return
|
||||||
|
|
||||||
if ! account_verified "$1"; then
|
if ! account_verified "$1"; then
|
||||||
data="$(cat secret/mail.dat | grep -P "^$1:")"
|
local data="$(cat secret/mail.dat | grep -P "^$1:")"
|
||||||
|
|
||||||
user="$1"
|
local user="$1"
|
||||||
mail="$(awk -F: '{print $2}' <<< "$data")"
|
local mail="$(awk -F: '{print $2}' <<< "$data")"
|
||||||
old_code="$(awk -F: '{print $3}' <<< "$data")"
|
local old_code="$(awk -F: '{print $3}' <<< "$data")"
|
||||||
timestamp="$(awk -F: '{print $5}' <<< "$data")"
|
local timestamp="$(awk -F: '{print $5}' <<< "$data")"
|
||||||
|
|
||||||
new_timestamp="$(date "+%s")"
|
local new_timestamp="$(date "+%s")"
|
||||||
new_code="$RANDOM"
|
local new_code="$RANDOM"
|
||||||
|
|
||||||
if [[ $(date "+%s") -gt $((timestamp+3600)) || $2 == true ]]; then
|
if [[ $(date "+%s") -gt $((timestamp+3600)) || $2 == true ]]; then
|
||||||
sed -i "s/$user:$mail:$old_code:yes:$timestamp/$user:$mail:$new_code:yes:$new_timestamp/" secret/mail.dat
|
sed -i "s/$user:$mail:$old_code:yes:$timestamp/$user:$mail:$new_code:yes:$new_timestamp/" secret/mail.dat
|
||||||
|
@ -129,9 +130,9 @@ function account_gen_reset_code() {
|
||||||
#reset_pwd(username, hash, password)
|
#reset_pwd(username, hash, password)
|
||||||
function reset_pwd() {
|
function reset_pwd() {
|
||||||
[[ "$1" == '' || "$2" == '' || "$3" == '' ]] && return
|
[[ "$1" == '' || "$2" == '' || "$3" == '' ]] && return
|
||||||
user="$1"
|
local user="$1"
|
||||||
hash="$2"
|
local hash="$2"
|
||||||
pass="$3"
|
local pass="$3"
|
||||||
|
|
||||||
if [[ "$(echo -n $(cat secret/mail.dat | grep -P "^$user:" | awk -F: '{print $3}')$(date "+%d%m%y") | sha1sum | awk '{print $1}' | cut -c 1-10)" == "$hash" ]]; then
|
if [[ "$(echo -n $(cat secret/mail.dat | grep -P "^$user:" | awk -F: '{print $3}')$(date "+%d%m%y") | sha1sum | awk '{print $1}' | cut -c 1-10)" == "$hash" ]]; then
|
||||||
delete_account "$user"
|
delete_account "$user"
|
||||||
|
|
|
@ -4,7 +4,7 @@ source "${cfg[namespace]}/code/common.sh"
|
||||||
if [[ "${post_data[login]}" != '' && "${post_data[password]}" != '' ]]; then
|
if [[ "${post_data[login]}" != '' && "${post_data[password]}" != '' ]]; then
|
||||||
login "${post_data[login]}" "${post_data[password]}"
|
login "${post_data[login]}" "${post_data[password]}"
|
||||||
status=$?
|
status=$?
|
||||||
if account_verified "${post_data[login]}"; then
|
if [[ $status == 0 ]] && account_verified "${post_data[login]}"; then
|
||||||
status=-2
|
status=-2
|
||||||
reason="Account not verified"
|
reason="Account not verified"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue