<? 
/*error_reporting(E_ALL);
ini_set('display_errors', '1');*/
session_start();
$nonce = bin2hex(random_bytes(16));

// Set secure headers including the nonce for inline scripts
header("X-Content-Type-Options: nosniff");
header("Content-Security-Policy: default-src 'self'; script-src 'self' 'nonce-$nonce'; style-src 'self' 'unsafe-inline'; img-src 'self' data:");
ob_start();
require_once "../../../controllers/core/inc.login.php";
include 'pass_var.php';

	
if($_SESSION['mmsg']!=''){
	unset($_SESSION['pass_changer_user_id']);
    unset($_SESSION['pass_changer_email']);
	}

$cid='robi';
unset($_SESSION['pass_changer_user_id']);
unset($_SESSION['pass_changer_email']);

if(isset($_POST['ibssignin']))
{



  $passward 	= auth_encode_sha256($_POST['pass']);
  $uid  		= $_POST['uid'];

	if(check_for_login_vendor($cid,$uid,$passward,1)){
		$_SESSION["user_type"] = "vendor";
        // echo 'Supplier';
    $sql="SELECT * FROM vendor WHERE email='$uid' and ".$pvalue."='$passward'";
	$qry = db_query($sql);
	$item = mysqli_fetch_object($qry);
	
	if ($item->pass_change=='YES') {
    echo "
    <form id='postForm' method='POST' action='otp_verification.php'>
          <input type='hidden' name='user_email' value='".$uid."' />
        <input type='hidden' name='ibssignin' value='1' />
    </form>
    <script nonce='$nonce'>
        document.getElementById('postForm').submit();
    </script>
    ";

	}else{
		header("Location:update_pass.php");
	}
	
	exit;

	}else {
		// echo "password not match";
		session_destroy();
		$msg="Invalid Login Information!!!";
	}
}

require_once "../../../controllers/routing/login_interface2.php";
?>
