X-Git-Url: https://git.plutz.net/?p=cgilite;a=blobdiff_plain;f=users.sh;h=1959e9de4b757084fad3d850b1b7b771517cb3c3;hp=f616ca02baca5d07c7199640ab436e064f4d405a;hb=HEAD;hpb=bfef1a064081f6f31ef90539e72dda84e6b563c8 diff --git a/users.sh b/users.sh index f616ca0..32299ff 100755 --- a/users.sh +++ b/users.sh @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright 2021 - 2023 Paul Hänsch +# Copyright 2021 - 2024 Paul Hänsch # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -17,8 +17,8 @@ [ -n "$include_users" ] && return 0 include_users="$0" -. "${_EXEC}/cgilite/session.sh" -. "${_EXEC}/cgilite/storage.sh" +. "${_EXEC:-.}/cgilite/session.sh" +. "${_EXEC:-.}/cgilite/storage.sh" SENDMAIL=${SENDMAIL-sendmail} @@ -29,9 +29,8 @@ USER_ACCOUNTPAGE="${USER_ACCOUNTPAGE}" USER_ACCOUNTEXPIRE="${USER_ACCOUNTEXPIRE:-$((86400 * 730))}" USER_CONFIRMEXPIRE="${USER_CONFIRMEXPIRE:-86400}" -MAILFROM="${MAILDOMAIN-noreply@${HTTP_HOST%:*}}" - HTTP_HOST="$(HEADER Host)" +MAILFROM="noreply@${HTTP_HOST%:*}" [ "$HTTPS" ] && SCHEMA=https || SCHEMA=http @@ -274,7 +273,7 @@ user_register(){ fi if [ "$USER_REQUIREEMAIL" = true ]; then - if [ ! "email" ]; then + if [ ! "$email" ]; then REDIRECT "${_BASE}${PATH_INFO}#ERROR_EMAIL_INVALID" elif user_emailexist "$email"; then REDIRECT "${_BASE}${PATH_INFO}#ERROR_EMAIL_EXISTS" @@ -342,7 +341,7 @@ user_invite(){ local email="$(POST email |user_checkemail)" local message="$(POST message)" - if [ ! "email" ]; then + if [ ! "$email" ]; then REDIRECT "${_BASE}${PATH_INFO}#ERROR_EMAIL_INVALID" elif user_emailexist "$email"; then REDIRECT "${_BASE}${PATH_INFO}#ERROR_EMAIL_EXISTS" @@ -429,7 +428,7 @@ user_update(){ uid="$(POST uid)" oldpw="$(POST oldpw)" - pw="$(POST pw |grep -xE '.{6}')" + pw="$(POST pw |grep -m1 -xE '.{6,}')" pwconfirm="$(POST pwconfirm)" @@ -442,7 +441,7 @@ user_update(){ update_user "${uid}" password="$pw" REDIRECT "${_BASE}${PATH_INFO}#UPDATE_SUCCESS" else - REDIRECT "${_BASE}${PATH_INFO}#ERROR_PWMISMATCH" + REDIRECT "${_BASE}${PATH_INFO}#ERROR_PW_MISMATCH" fi elif [ "$UID_" = "$USER_ID" ]; then REDIRECT "${_BASE}${PATH_INFO}#ERROR_INVALID_AUTH_PASSWORD" @@ -622,7 +621,7 @@ w_user_invite(){ if [ "$(GET user_confirm)" ]; then w_user_confirm - elif [ "$USER_ID" -a "$SENDMAIL" ]; then + elif [ "$USER_ID" -a "$USER_REQUIREEMAIL" = true ]; then w_user_invite_email elif [ "$USER_ID" ]; then uid="$(timeid)"