New users need to verify email

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
liontaur
Posts: 2
Joined: 2015-06-06 04:54
Location: Salmon Arm, BC, Canada

New users need to verify email

Post by liontaur » 2015-06-06 04:56

Hello all,

Just wondering if there's a way to make it so that any new users who sign up can be emailed a verification link that they need to click on in order to be approved instead of the admin needing to approve them?

Thanks,

Mark

User avatar
shasta59
AppGini Super Hero
AppGini Super Hero
Posts: 231
Joined: 2013-01-08 19:40
Location: Calgary, Alberta, Canada

Re: New users need to verify email

Post by shasta59 » 2015-06-08 01:32

What version are you using? It is nice to know this as it can make a difference in answers.
I am still using 5.31

You can set it so they are automatically verified when they sign up. They will be sent an url to go to to log in.

However if you are looking for code to email them and they click and it goes to a page you could adapt the same code AppGini has for sending out the "you forgot your password" notice. It would not be hard to duplicate then revise it to work as a check system for new signups.

You would need to have the click contain the necessary information to verify. I cannot see it being very hard to do but it does not exist at this time.

If you get it working and want to share that would be nice.

Alan
Calgary, Alberta, Canada - Using Appgini 5.50 -

liontaur
Posts: 2
Joined: 2015-06-06 04:54
Location: Salmon Arm, BC, Canada

Re: New users need to verify email

Post by liontaur » 2015-06-08 05:42

Thanks for the reply Alan. I've just bought version 5.40. I think i've got it sorted for the interim by using shell scripting. It's ugly as can be but here it is. I've edited the global hook to run this script after a new user signs up. I had planned to just use a cronjob to run it periodically but then stumbled upon the hook functionality:

Code: Select all

#!/usr/local/bin/bash
Folder="/usr/local/www/PHP/pp_scripts"
USER=""
PASS=""
DB=""
SEL="select email, memberID"
TBL="membership_users"
WHC1="isApproved=0"
WHC2="custom3=''"
Q1="$SEL from $TBL"
Q2="where $WHC1 and $WHC2"
QRY="$Q1 $Q2"
/usr/local/bin/mysql -u$USER -p$PASS $DB -e "$QRY" > $Folder/templist_with_tabs.lst
if [[ -s $Folder/templist_with_tabs.lst ]] ; then
  expand -t 1 $Folder/templist_with_tabs.lst > $Folder/templist.lst
  rm $Folder/templist_with_tabs.lst
  tail -n +2 $Folder/templist.lst > $Folder/new_user_list.lst
  rm $Folder/templist.lst
#  cat
  while [ -s $Folder/new_user_list.lst ];
  do
    DATESHA=$(/usr/local/bin/gdate -Ins | sha256)
    head -1 $Folder/new_user_list.lst > $Folder/validate/$DATESHA.txt
    tail -n +2 $Folder/new_user_list.lst > $Folder/templist.lst
    mv $Folder/templist.lst $Folder/new_user_list.lst
    USER=$(cat $Folder/validate/$DATESHA.txt)
    USER_EMAIL=${USER% *}
    USER_NAME=${USER##* }
    Single_quote="'"
    Double_quote='"'
    SQL_VAR='$sql = '
    UPDATE_VAR="UPDATE membership_users SET isApproved=1"
    WHERE_VAR="WHERE memberID='$USER_NAME'"
    echo $SQL_VAR $Double_quote$UPDATE_VAR $WHERE_VAR$Double_quote";" > $Folder/php_script/link.txt
    cat $Folder/php_script/header.txt $Folder/php_script/link.txt $Folder/php_script/footer.txt > /usr/local/www/PHP/validate/$DATESHA.php
    rm $Folder/php_script/link.txt
    echo "http://192.168.10.30/PHP/validate/$DATESHA.php" > $Folder/form_letter/link.txt
    cat $Folder/form_letter/body_of_email.txt $Folder/form_letter/link.txt $Folder/form_letter/footer_of_email.txt | /usr/bin/mail -s "Email verification" "$USER_EMAIL"
    rm $Folder/form_letter/link.txt
  done
rm $Folder/new_user_list.lst
fi

Post Reply