/** * Attempt a login; on success setup session vars and send to node server else log the failed attempt * @param $username * @param $password * @return bool|int */ public function customerLogin($username, $password) { $custMdl = new CustomerModel(); $customer = $custMdl->login($username, $password, true); if ($customer == -1) { // log data Logger::write("An authentication attempt was made by " . $username . " but the customer has been disabled.", "AUTH"); return -1; // the user is disabled } if ($customer == -2) { return -2; // the user is not activated } if (is_array($customer)) { // check for $_SESSION['cust_username'] = $username; $_SESSION['cust_name'] = $customer['name']; $_SESSION['cust_id'] = $customer['id']; $_SESSION['cust_hash'] = $customer['pass']; // log data Logger::write("Authentication successful for customer:" . $username, "AUTH"); return true; } else { // log data Logger::write("Authentication failed for customer:" . $username . " with hash:" . $password, "AUTH"); return false; } }