#!/bin/sh
#
# This script gets login and password and checks if the user exists and can login.
#

test -n "$COMMON_LIB_PATH" || COMMON_LIB_PATH="`dirname $0`"
. "${COMMON_LIB_PATH}/common.sh"

read_input_parameters

user_id=""
login="$param1"
password="$param2"
if test -n "$login" && test -n "$password"; then
	user_account="`user_account_by_login $login`"
	if test -n "$user_account" && test "$password" = "`echo $user_account | awk -F: '{print $2}'`"; then
		user_id="`echo $user_account | awk -F: '{print $3}'`"
	fi
fi
if [ -n "$user_id" ]; then
	send_line "$user_id"
else
	send_error "authentication failure"
fi

send_end

