| ';
print $langs->trans("SupplierOrder").' | ';
print '';
@@ -2477,26 +2476,25 @@ if ($action == 'create' && $permissiontoadd) {
// Get list of products already sent for same source object into $alreadysent
$alreadysent = array();
- //$origin = 'commande_fournisseur';
+ if (empty($origin)) {
+ $origin = 'supplier_order';
+ }
if ($origin && $origin_id > 0) {
$sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end";
$sql .= ", ed.rowid as receptionline_id, ed.qty, ed.fk_reception as reception_id, ed.fk_entrepot";
$sql .= ", e.rowid as reception_id, e.ref as reception_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_reception";
- //if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received";
$sql .= ', p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch';
$sql .= ', p.description as product_desc';
$sql .= " FROM ".MAIN_DB_PREFIX."receptiondet_batch as ed";
$sql .= ", ".MAIN_DB_PREFIX."reception as e";
- $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj";
- //if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_reception = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line";
+ $sql .= ", ".MAIN_DB_PREFIX.(($origin == 'supplier_order') ? 'commande_fournisseur' : $origin)."det as obj";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid";
$sql .= " WHERE e.entity IN (".getEntity('reception').")";
$sql .= " AND obj.fk_commande = ".((int) $origin_id);
$sql .= " AND obj.rowid = ed.fk_elementdet";
$sql .= " AND ed.fk_reception = e.rowid";
$sql .= " AND ed.fk_reception !=".((int) $object->id);
- //if ($filter) $sql.= $filter;
$sql .= " ORDER BY obj.fk_product";
dol_syslog("get list of reception lines", LOG_DEBUG);
diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php
index 0ead07ec0d0..a6cdddd9c0e 100644
--- a/htdocs/reception/class/reception.class.php
+++ b/htdocs/reception/class/reception.class.php
@@ -336,7 +336,7 @@ class Reception extends CommonObject
$sql .= ", fk_incoterms, location_incoterms";
$sql .= ") VALUES (";
$sql .= "'(PROV)'";
- $sql .= ", ".((int) $conf->entity);
+ $sql .= ", ".((int) $this->entity);
$sql .= ", ".($this->ref_supplier ? "'".$this->db->escape($this->ref_supplier)."'" : "null");
$sql .= ", '".$this->db->idate($this->date_creation)."'";
$sql .= ", ".((int) $user->id);
@@ -746,7 +746,7 @@ class Reception extends CommonObject
}
}
- if (!$error) {
+ if (!$error && $this->origin_id > 0) {
// Change status of purchase order to "reception in process" or "totally received"
$status = $this->getStatusDispatch();
if ($status < 0) {
diff --git a/htdocs/reception/dispatch.php b/htdocs/reception/dispatch.php
index e901cde50c8..f1bb7e61a6b 100644
--- a/htdocs/reception/dispatch.php
+++ b/htdocs/reception/dispatch.php
@@ -322,7 +322,6 @@ llxHeader('', $title, $help_url, '', 0, 0, $morejs, '', '', 'mod-reception page-
if ($id > 0 || !empty($ref)) {
$typeobject = '';
if (!empty($object->origin) && $object->origin_id > 0) {
- $object->origin = 'CommandeFournisseur';
$typeobject = $object->origin;
$origin = $object->origin;
$origin_id = $object->origin_id;
@@ -418,7 +417,7 @@ if ($id > 0 || !empty($ref)) {
print " | \n";
print '
';
}
- if ($typeobject == 'CommandeFournisseur' && $object->origin_object->id && isModEnabled("propal")) {
+ if (($typeobject == 'supplier_order' || $typeobject == 'order_supplier') && $object->origin_object->id && isModEnabled("propal")) {
print '| ';
print $langs->trans("SupplierOrder").' | ';
print '';
diff --git a/htdocs/webportal/class/context.class.php b/htdocs/webportal/class/context.class.php
index 0120f30ef1e..11eea65bafd 100644
--- a/htdocs/webportal/class/context.class.php
+++ b/htdocs/webportal/class/context.class.php
@@ -476,6 +476,8 @@ class Context
if (!empty($_SESSION["webportal_logged_thirdparty_account_id"])) {
return true;
+ } elseif (!empty($_SESSION["webportal_logged_member_account_id"])) {
+ return true;
} else {
return false;
}
@@ -720,29 +722,16 @@ class Context
if ($obj) {
$passcrypted = $obj->pass_crypted;
- // Check crypted password
- $cryptType = '';
- if (getDolGlobalString('DATABASE_PWD_ENCRYPTED')) {
- $cryptType = getDolGlobalString('DATABASE_PWD_ENCRYPTED');
- }
-
- // By default, we use default setup for encryption rule
- if (!in_array($cryptType, array('auto'))) {
- $cryptType = 'auto';
- }
-
// Check crypted password according to crypt algorithm
- if ($cryptType == 'auto') {
- if ($passcrypted && dol_verifyHash($pass, $passcrypted, '0')) {
- $passok = true;
- }
+ if ($passcrypted && dol_verifyHash($pass, $passcrypted, '0')) {
+ $passok = true;
}
// Password ok ?
if ($passok) {
$id = $obj->id;
} else {
- dol_syslog(__METHOD__ .' Authentication KO bad password for ' . $login . ', cryptType=' . $cryptType, LOG_NOTICE);
+ dol_syslog(__METHOD__ .' Authentication KO bad password for ' . $login . ', cryptType=auto', LOG_NOTICE);
sleep(1); // Brut force protection. Must be same delay when login is not valid
return -3;
}
@@ -758,4 +747,56 @@ class Context
return $id;
}
+
+ /**
+ * Try to find the member account id from
+ *
+ * @param string $login Login
+ * @param string $pass Password
+ * @return int Member account id || <0 if error
+ */
+ public function getMemberAccountFromLogin($login, $pass)
+ {
+ $id = 0;
+
+ $sql = "SELECT a.rowid as id, a.pass_crypted";
+ $sql .= " FROM " . $this->db->prefix() . "adherent as a";
+ $sql .= " WHERE a.login = '" . $this->db->escape($login) . "'";
+ $sql .= " AND a.statut = 1";
+ $sql .= " AND a.entity IN (" . getEntity('member') . ")";
+
+ dol_syslog(__METHOD__ . ' Try to find the member account id for login"' . $login . '"', LOG_DEBUG);
+ $result = $this->db->query($sql);
+ if ($result) {
+ if ($this->db->num_rows($result) == 1) {
+ $passok = false;
+ $obj = $this->db->fetch_object($result);
+ if ($obj) {
+ $passcrypted = $obj->pass_crypted;
+
+ // Check crypted password according to crypt algorithm
+ if ($passcrypted && dol_verifyHash($pass, $passcrypted, '0')) {
+ $passok = true;
+ }
+
+ // Password ok ?
+ if ($passok) {
+ $id = $obj->id;
+ } else {
+ dol_syslog(__METHOD__ .' Authentication KO bad password for ' . $login . ', cryptType=auto', LOG_NOTICE);
+ sleep(1); // Brut force protection. Must be same delay when login is not valid
+ return -3;
+ }
+ }
+ } else {
+ dol_syslog(__METHOD__ . ' Many member account found for login"' . $login . '"', LOG_ERR);
+ return -2;
+ }
+ } else {
+ $this->error = $this->db->lasterror();
+ return -1;
+ }
+
+ return $id;
+ }
}
diff --git a/htdocs/workstation/class/api_workstations.class.php b/htdocs/workstation/class/api_workstations.class.php
index f15c779e6bd..68e600143a1 100644
--- a/htdocs/workstation/class/api_workstations.class.php
+++ b/htdocs/workstation/class/api_workstations.class.php
@@ -197,13 +197,13 @@ class Workstations extends DolibarrApi
{
// phpcs:enable
$object = parent::_cleanObjectDatas($object);
+ /** @var Workstation $object */
unset($object->statut);
unset($object->regeximgext);
unset($object->price_by_qty);
unset($object->prices_by_qty_id);
- unset($object->libelle);
unset($object->product_id_already_linked);
unset($object->reputations);
unset($object->db);
diff --git a/test/hurl/api/comm/propal/10_propal.hurl b/test/hurl/api/comm/propal/10_propal.hurl
index 4121ca0eacc..6dd1a46c448 100644
--- a/test/hurl/api/comm/propal/10_propal.hurl
+++ b/test/hurl/api/comm/propal/10_propal.hurl
@@ -84,8 +84,12 @@ HTTP 200
# GET proposals DOLAPIENTITY: 2
GET http://{{hostnport}}/api/index.php/proposals
DOLAPIENTITY: 2
-HTTP 403
-{"error":{"code":403,"message":"Forbidden"}}
+HTTP 401
+[Asserts]
+jsonpath "$.error" exists
+jsonpath "$.error.code" == 401
+jsonpath "$.error.message" contains "Unauthorized"
+jsonpath "$.error.message" contains "Token not valid (may be a typo or a wrong entity)"
# Capture a proposal ID number
GET http://{{hostnport}}/api/index.php/proposals?limit=1
diff --git a/test/hurl/api/commande/10_commande.hurl b/test/hurl/api/commande/10_commande.hurl
index 2dbded46fc5..e2007a82e5e 100644
--- a/test/hurl/api/commande/10_commande.hurl
+++ b/test/hurl/api/commande/10_commande.hurl
@@ -84,8 +84,13 @@ HTTP 200
# GET orders DOLAPIENTITY: 2
GET http://{{hostnport}}/api/index.php/orders
DOLAPIENTITY: 2
-HTTP 403
-{"error":{"code":403,"message":"Forbidden"}}
+HTTP 401
+[Asserts]
+jsonpath "$.error" exists
+jsonpath "$.error.code" == 401
+jsonpath "$.error.message" contains "Unauthorized"
+jsonpath "$.error.message" contains "Token not valid (may be a typo or a wrong entity)"
+
# Capture a order ID number
GET http://{{hostnport}}/api/index.php/orders?limit=1
diff --git a/test/hurl/api/compta/facture/10_facture.hurl b/test/hurl/api/compta/facture/10_facture.hurl
index beac6d8500f..6ffe7b11c4f 100644
--- a/test/hurl/api/compta/facture/10_facture.hurl
+++ b/test/hurl/api/compta/facture/10_facture.hurl
@@ -77,8 +77,12 @@ HTTP 200
# GET invoices DOLAPIENTITY: 2
GET http://{{hostnport}}/api/index.php/invoices
DOLAPIENTITY: 2
-HTTP 403
-{"error":{"code":403,"message":"Forbidden"}}
+HTTP 401
+[Asserts]
+jsonpath "$.error" exists
+jsonpath "$.error.code" == 401
+jsonpath "$.error.message" contains "Unauthorized"
+jsonpath "$.error.message" contains "Token not valid (may be a typo or a wrong entity)"
# Capture a invoice ID number
GET http://{{hostnport}}/api/index.php/invoices?limit=1
|