OpenVPN-Admin/installation/scripts/login.sh

8 lines
581 B
Bash
Raw Normal View History

2014-03-21 21:18:50 +01:00
#!/bin/bash
. /etc/openvpn/scripts/config.sh
# Authentication
2014-03-21 21:21:50 +01:00
user_id=$(mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -sN -e "SELECT user_id FROM user WHERE user_id = '$username' AND user_pass = SHA1('$password') AND user_enable=1 AND (TO_DAYS(now()) >= TO_DAYS(user_start_date) OR user_start_date='0000-00-00') AND (TO_DAYS(now()) <= TO_DAYS(user_end_date) OR user_end_date='0000-00-00')")
2014-03-21 21:18:50 +01:00
# Vérification de l'utilisateur
2015-07-09 14:26:07 +02:00
[ "$user_id" != '' ] && [ "$user_id" = "$username" ] && echo "user : $username" && echo 'authentication ok.' && exit 0 || echo 'authentication failed.'; exit 1