<?php

	// Check nonce
	PHPCUS_PARAM::CUS_REQUIRES_NONCE();
	
	// Check Array Input
	PHPCUS_PARAM::CUS_DOES_NOT_SUPPORT_ARRAY();
	
	// Check already authenticated
	if(PHPCUS_PARAM::CUS_IS_AUTHENTICATED() === True)
	{}
	
	// Process request
	if
	(
			PHPRC_HTTP_PARAM::REF_ISSET_IN_ARRAY
			(
					[
							'PARAM_ACCOUNT_USERNAME',
							'PARAM_ACCOUNT_PASSWORD'
					], True
			)
	)
	{
		Try
		{

			
			// Read params
			// ------------------------------------------------------------------
			$PARAM_ACCOUNT_USERNAME = PHPCUS_PARAM::CUS_READ_NVARCHAR('PARAM_ACCOUNT_USERNAME');
			$PARAM_ACCOUNT_PASSWORD = PHPCUS_PARAM::CUS_READ_NVARCHAR('PARAM_ACCOUNT_PASSWORD');
			// ------------------------------------------------------------------
					
			// Execute Stored Procedure
			$DATA_SET = PHPCUS_Account_Member::CUS_VERIFY_PASSWORD
						(
								$PARAM_ACCOUNT_USERNAME, 
								$PARAM_ACCOUNT_PASSWORD
						);
						
			// Return JSON response
			if($DATA_SET === True)
			{
				PHPCUS_PARAM::CUS_JSON_SUCCESS('');	
			}
			else
			{
				PHPCUS_PARAM::CUS_JSON_ERROR('Invalid username or password.');
			}
			
		}
		Catch(Exception $ERR)
		{
			PHPVC_LOG::VAR_REPORT_ERROR($ERR, 0);
			PHPCUS_PARAM::CUS_JSON_ERROR($ERR->getMessage());
		}
	}
	else
	{
		PHPCUS_PARAM::CUS_JSON_ERROR('Missing parameters');
	}

?>