aboutsummaryrefslogtreecommitdiff
path: root/auth
diff options
context:
space:
mode:
authorMaria Lisina <sekoohaka.sarisan@gmail.com>2025-09-22 17:43:38 +0500
committerMaria Lisina <sekoohaka.sarisan@gmail.com>2025-09-22 17:44:30 +0500
commit53714957d4bed97ecd95005643e7abbd22585df6 (patch)
tree195c0b0eee6fbfdc133b3bdddd04df6602d6327d /auth
parent3acb0da586da283c94ef18e7df792af3cafdfbdf (diff)
auth/*: Update auth units to follow new standard
Signed-off-by: Maria Lisina <sekoohaka.sarisan@gmail.com>
Diffstat (limited to 'auth')
-rw-r--r--auth/donmai.zsh42
-rw-r--r--auth/moebooru.zsh35
-rw-r--r--auth/sankakucomplex.zsh44
3 files changed, 55 insertions, 66 deletions
diff --git a/auth/donmai.zsh b/auth/donmai.zsh
index f6f445f..e957fd8 100644
--- a/auth/donmai.zsh
+++ b/auth/donmai.zsh
@@ -2,49 +2,45 @@
# Copyright (C) 2024-2025 Danil Lisin
# SPDX-License-Identifier: Apache-2.0
-ib_auth_file="${cache}/${update_id}_profile.json"
-dump+=(${ib_auth_file##*/})
-
-if ! curl --connect-timeout ${connrefused_timeout} \
- --max-time ${external_timeout} \
- --output "${ib_auth_file}" \
- --proxy "${external_proxy}" \
- --request GET \
- --retry 1 \
- --retry-connrefused \
- --retry-max-time $((external_timeout - connrefused_timeout)) \
- --silent \
- --user "${ib_login}:${ib_key}" \
- --user-agent "${useragent}" \
- "${ib_auth}/profile.json"
+if ! ib_auth_data="$(
+ curl --connect-timeout ${connrefused_timeout} \
+ --max-time ${external_timeout} \
+ --proxy "${external_proxy}" \
+ --request GET \
+ --retry 1 \
+ --retry-connrefused \
+ --retry-max-time $((external_timeout - connrefused_timeout)) \
+ --silent \
+ --user "${ib_login}:${ib_key}" \
+ --user-agent "${useragent}" \
+ "${ib_auth}/profile.json"
+)"
then
output_text="Failed to access ${ib_name} API"
- log_text="ib_auth (${update_id}): ${output_text}"
+ log_text="ib_auth (${update_id}): ${output_text}"
. "${units}/log.zsh"
- . "${units}/dump.zsh"
return 0
fi
-if ! jq -e '.' "${ib_auth_file}" > /dev/null
+if ! jq -e '.' <<< "${ib_auth_data}" > /dev/null
then
output_text="An unknown error occurred"
- log_text="ib_auth (${update_id}): ${output_text}"
+ log_text="ib_auth (${update_id}): ${output_text}"
. "${units}/log.zsh"
- . "${units}/dump.zsh"
return 0
fi
-if [[ "$(jq -r '.success' "${ib_auth_file}")" == "false" ]]
+if [[ "$(jq -r '.success' <<< "${ib_auth_data}")" == "false" ]]
then
- output_text="Error: <code>$(jq -r '.message' "${ib_auth_file}" | htmlescape)</code>"
+ output_text="Error: <code>$(jq -r '.message' <<< "${ib_auth_data}" | htmlescape)</code>"
return 0
fi
-if [[ "$(jq -r '.name' "${ib_auth_file}")" != "${ib_login}" ]]
+if [[ "$(jq -r '.name' <<< "${ib_auth_data}")" != "${ib_login}" ]]
then
output_text="Failed to verify user authorization"
return 0
diff --git a/auth/moebooru.zsh b/auth/moebooru.zsh
index 5458b11..1c3d573 100644
--- a/auth/moebooru.zsh
+++ b/auth/moebooru.zsh
@@ -2,33 +2,30 @@
# Copyright (C) 2024-2025 Danil Lisin
# SPDX-License-Identifier: Apache-2.0
-ib_auth_file="${cache}/${update_id}_user.json"
-dump+=(${ib_auth_file##*/})
-
-if ! curl --connect-timeout ${connrefused_timeout} \
- --data-urlencode "username=${ib_login}" \
- --data-urlencode "api_key=${ib_key}" \
- --get \
- --max-time ${external_timeout} \
- --output "${ib_auth_file}" \
- --proxy "${external_proxy}" \
- --retry 1 \
- --retry-connrefused \
- --retry-max-time $((external_timeout - connrefused_timeout)) \
- --silent \
- --user-agent "${useragent}" \
- "${ib_auth}/user.json"
+if ! ib_auth_data="$(
+ curl --connect-timeout ${connrefused_timeout} \
+ --data-urlencode "username=${ib_login}" \
+ --data-urlencode "api_key=${ib_key}" \
+ --get \
+ --max-time ${external_timeout} \
+ --proxy "${external_proxy}" \
+ --retry 1 \
+ --retry-connrefused \
+ --retry-max-time $((external_timeout - connrefused_timeout)) \
+ --silent \
+ --user-agent "${useragent}" \
+ "${ib_auth}/user.json"
+)"
then
output_text="Failed to access ${ib_name} API"
- log_text="ib_auth (${update_id}): ${output_text}"
+ log_text="ib_auth (${update_id}): ${output_text}"
. "${units}/log.zsh"
- . "${units}/dump.zsh"
return 0
fi
-if ! jq -e '.' "${ib_auth_file}" > /dev/null
+if ! jq -e '.' <<< "${ib_auth_data}" > /dev/null
then
output_text="Invalid username or API key"
fi
diff --git a/auth/sankakucomplex.zsh b/auth/sankakucomplex.zsh
index 45b9d3a..3eabc78 100644
--- a/auth/sankakucomplex.zsh
+++ b/auth/sankakucomplex.zsh
@@ -9,48 +9,44 @@ ib_login_data="$(
'{"login": $login, "password": $password}'
)"
-ib_auth_file="${cache}/${update_id}_token.json"
-dump+=(${ib_auth_file##*/})
-
-if ! curl --connect-timeout ${connrefused_timeout} \
- --data "${ib_login_data}" \
- --header "Content-Type: application/json" \
- --max-time ${external_timeout} \
- --output "${ib_auth_file}" \
- --proxy "${external_proxy}" \
- --request POST \
- --retry 1 \
- --retry-connrefused \
- --retry-max-time $((external_timeout - connrefused_timeout)) \
- --silent \
- --user-agent "${useragent}" \
- "${ib_auth}/auth/token"
+if ! ib_auth_data="$(
+ curl --connect-timeout ${connrefused_timeout} \
+ --data "${ib_login_data}" \
+ --header "Content-Type: application/json" \
+ --max-time ${external_timeout} \
+ --proxy "${external_proxy}" \
+ --request POST \
+ --retry 1 \
+ --retry-connrefused \
+ --retry-max-time $((external_timeout - connrefused_timeout)) \
+ --silent \
+ --user-agent "${useragent}" \
+ "${ib_auth}/auth/token"
+)"
then
output_text="Failed to access ${ib_name} API"
- log_text="ib_auth (${update_id}): ${output_text}"
+ log_text="ib_auth (${update_id}): ${output_text}"
. "${units}/log.zsh"
- . "${units}/dump.zsh"
return 0
fi
-if ! jq -e '.' "${ib_auth_file}" > /dev/null
+if ! jq -e '.' <<< "${ib_auth_data}" > /dev/null
then
output_text="An unknown error occurred"
- log_text="ib_auth (${update_id}): ${output_text}"
+ log_text="ib_auth (${update_id}): ${output_text}"
. "${units}/log.zsh"
- . "${units}/dump.zsh"
return 0
fi
-if [[ "$(jq -r '.success' "${ib_auth_file}")" != "true" ]]
+if [[ "$(jq -r '.success' <<< "${ib_auth_data}")" != "true" ]]
then
- output_text="Error: <code>$(jq -r '.error' "${ib_auth_file}" | htmlescape)</code>"
+ output_text="Error: <code>$(jq -r '.error' <<< "${ib_auth_data}" | htmlescape)</code>"
return 0
fi
-jq -r '.access_token' "${ib_auth_file}" > "${token_file}"
+jq -r '.access_token' <<< "${ib_auth_data}" > "${token_file}"
strftime %s > "${timestamp_file}"