You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
790 B
26 lines
790 B
11 years ago
|
#!/bin/bash
|
||
|
. /etc/openvpn/scripts/config.sh
|
||
9 years ago
|
. /etc/openvpn/scripts/functions.sh
|
||
|
|
||
|
username=$(echap "$username")
|
||
|
password=$(echap "$password")
|
||
11 years ago
|
|
||
|
# Authentication
|
||
8 years ago
|
user_pass=$(mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -sN -e "SELECT user_pass FROM user WHERE user_id = '$username' AND user_enable=1 AND (TO_DAYS(now()) >= TO_DAYS(user_start_date) OR user_start_date IS NULL) AND (TO_DAYS(now()) <= TO_DAYS(user_end_date) OR user_end_date IS NULL)")
|
||
11 years ago
|
|
||
10 years ago
|
# Check the user
|
||
10 years ago
|
if [ "$user_pass" == '' ]; then
|
||
|
echo "$username: bad account."
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
result=$(php -r "if(password_verify('$password', '$user_pass') == true) { echo 'ok'; } else { echo 'ko'; }")
|
||
|
|
||
|
if [ "$result" == "ok" ]; then
|
||
|
echo "$username: authentication ok."
|
||
|
exit 0
|
||
|
else
|
||
|
echo "$username: authentication failed."
|
||
|
exit 1
|
||
|
fi
|