From: Paul Hänsch Date: Wed, 18 May 2022 20:33:46 +0000 (+0200) Subject: detect https/http schema for invite links X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=38314fd1bc5cdc37422e38de39c8212783d5a2a8;p=cgilite detect https/http schema for invite links --- diff --git a/users.sh b/users.sh index 254d61c..ca986cd 100755 --- a/users.sh +++ b/users.sh @@ -16,6 +16,8 @@ MAILFROM="${MAILDOMAIN-noreply@${HTTP_HOST%:*}}" HTTP_HOST="$(HEADER Host)" +[ "$HTTPS" ] && SCHEMA=https || SCHEMA=http + # == FILE FORMAT == # UID UNAME STATUS EMAIL PWSALT PWHASH EXPIRE DEVICES FUTUREUSE # (pending|active|deleted) @@ -233,7 +235,7 @@ user_register(){ REDIRECT "${_BASE}${PATH_INFO}#ERROR_EMAIL_EXISTS" elif new_user "$uid" status=pending email="$email" expire="$((_DATE + 86400))"; then debug "Sending Activation Link:" \ - "https://${HTTP_HOST}${_BASE}${PATH_INFO}?user_confirm=${uid}+$(session_mac "$uid")" + "${SCHEMA}://${HTTP_HOST}${_BASE}${PATH_INFO}?user_confirm=${uid}+$(session_mac "$uid")" "$SENDMAIL" -t -f "$MAILFROM" <<-EOF From: ${MAILFROM} To: ${email} @@ -243,7 +245,7 @@ user_register(){ You can activate your account using this link: - https://${HTTP_HOST}${_BASE}${PATH_INFO}?user_confirm=${uid}+$(session_mac "$uid") + ${SCHEMA}://${HTTP_HOST}${_BASE}${PATH_INFO}?user_confirm=${uid}+$(session_mac "$uid") This registration link will expire after 24 hours. @@ -295,7 +297,7 @@ user_invite(){ REDIRECT "${_BASE}${PATH_INFO}#ERROR_EMAIL_EXISTS" elif new_user "$uid" status=pending email="$email" expire="$((_DATE + 86400))"; then debug "Sending Invitation Link:" \ - "https://${HTTP_HOST}${_BASE}${PATH_INFO}?user_confirm=${uid}+$(session_mac "$uid")" + "${SCHEMA}://${HTTP_HOST}${_BASE}${PATH_INFO}?user_confirm=${uid}+$(session_mac "$uid")" "$SENDMAIL" -t -f "$MAILFROM" <<-EOF From: ${MAILFROM} To: ${email} @@ -307,7 +309,7 @@ user_invite(){ You can create your account using this link: - https://${HTTP_HOST}${_BASE}${PATH_INFO}?user_confirm=${uid}+$(session_mac "$uid") + ${SCHEMA}://${HTTP_HOST}${_BASE}${PATH_INFO}?user_confirm=${uid}+$(session_mac "$uid") This registration link will expire after 24 hours. @@ -555,7 +557,7 @@ w_user_invite(){ new_user "$uid" status=pending email="$email" expire="$((_DATE + 86400))" cat <<-EOF [p An anonymous user account has been set up. Send the following link to the intended user, so they may claim their account. The link will remain valid for 24 hours.] - [p . $(HTML "https://${HTTP_HOST}${_BASE}${PATH_INFO}?user_confirm=${uid}+$(session_mac "$uid")" |debug)] + [p . $(HTML "${SCHEMA}://${HTTP_HOST}${_BASE}${PATH_INFO}?user_confirm=${uid}+$(session_mac "$uid")" |debug)] [p [a href="#" . Set up another account]] EOF