Unverified Commit 01266511 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:ambulance: fix(user) Ease use of UserPasswordAttribute through webservices

Now array values are checked to have correct format, and string values
 are used as the new password using default password method.

issue #6052
Showing with 25 additions and 0 deletions
+25 -0
...@@ -255,4 +255,29 @@ class UserPasswordAttribute extends CompositeAttribute ...@@ -255,4 +255,29 @@ class UserPasswordAttribute extends CompositeAttribute
{ {
return $this->attributes[4]->getValue(); return $this->attributes[4]->getValue();
} }
/*! \brief Apply value from RPC requests
*
* \param mixed $value the value
*/
function deserializeValue ($value)
{
if ($this->disabled) {
return parent::deserializeValue($value);
}
if (is_array($value)) {
if (count($value) > 5) {
return sprintf(_('Too many elements in array value for password field %s: %d instead of %d'), $this->getLdapName(), count($value), 5);
} elseif (count($value) < 5) {
return sprintf(_('Not enough elements in array value for password field %s: %d instead of %d'), $this->getLdapName(), count($value), 5);
} elseif (!isset($value[0])) {
return sprintf(_('Array value for password field %s must have numeric keys'), $this->getLdapName());
}
$this->setValue($value);
} elseif (is_string($value)) {
$this->setValue(['', $value, $value, '', FALSE]);
} else {
return sprintf(_('Invalid value type for password field %s, must be array or string'), $this->getLdapName());
}
}
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment