diff --git a/ufw b/ufw index bceac34..28e909e 100755 --- a/ufw +++ b/ufw @@ -33,7 +33,7 @@ usage() { -P|--page-url # Get a link to the file page instead of a direct one. -m|--max-filesize [suf] # Maximum filesize (takes K, M and G suffixes). -a|--album-id # Add the file to an album. - -A|--album-name # Add the file to an album by name. The album will be crated, if necessary. + -A|--album-name # Add the file to an album by name. The album will be created, if necessary. Config options (~/.config/ufw): secret # Your personal token. Get it at https://zfh.so/settings_form @@ -221,6 +221,10 @@ get_api_status() { read -d '' -r api_status api_status_message < <( jshon -e status -e code -u -p -e message -u ) + + if ! (( api_status == 200 )); then + return 1 + fi } _mktemp() { @@ -253,6 +257,18 @@ get_my_ip() { fi } +login() { + declare api_response + + api_response=$( curl -sl "$cfg_service_url/$cfg_api_path/get_login_token?login=$login&format=json" ) + + if get_api_status <<< "$api_response"; then + printf 'Check your email.\n' + else + printf 'Error: %s %s\n' "$api_status" "$api_status_message" + fi +} + set_argv() { declare arg opt c declare -g argv @@ -355,6 +371,12 @@ main() { misc_curl_args+=( -F "description=$2" ) shift ;; + + -l|--login) + action='login' + login=$2 + shift + ;; -h|--help|--usage) usage; return;; @@ -371,6 +393,7 @@ main() { upload) upload "$1";; url) get_shortlink "$1";; getmyip) get_my_ip;; + login) login;; esac }