Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
fusiondirectory
fusiondirectory
Commits
6b15599e
Commit
6b15599e
authored
May 19, 2015
by
Côme Bernigaud
Committed by
Benoit Mortier
May 19, 2015
Browse files
Fixes
#2407
Adding back support for password method with no password (sasl for instance)
parent
7e25d258
Changes
1
Hide whitespace changes
Inline
Side-by-side
plugins/personal/generic/class_user.inc
View file @
6b15599e
...
...
@@ -21,16 +21,18 @@
/* Handle a password and its hash method */
class
UserPasswordAttribute
extends
CompositeAttribute
{
protected
$needPassword
;
protected
$previousMethod
;
function
__construct
(
$label
,
$description
,
$ldapName
,
$required
=
FALSE
,
$defaultValue
=
""
,
$acl
=
""
)
{
$temp
=
passwordMethod
::
get_available_methods
();
/* Create password methods array */
$pwd_methods
=
array
();
$this
->
needPassword
=
array
();
foreach
(
$temp
[
'name'
]
as
$id
=>
$name
)
{
if
(
!
$temp
[
$id
][
'object'
]
->
need_password
())
{
continue
;
}
$this
->
needPassword
[
$name
]
=
$temp
[
$id
][
'object'
]
->
need_password
();
$pwd_methods
[
$name
]
=
$name
;
if
(
!
empty
(
$temp
[
$id
][
'desc'
]))
{
$pwd_methods
[
$name
]
.
=
" ("
.
$temp
[
$id
][
'desc'
]
.
")"
;
...
...
@@ -63,6 +65,7 @@ class UserPasswordAttribute extends CompositeAttribute
),
''
,
''
,
$acl
,
$label
);
$this
->
attributes
[
0
]
->
setSubmitForm
(
TRUE
);
}
public
function
setParent
(
&
$plugin
)
...
...
@@ -75,6 +78,7 @@ class UserPasswordAttribute extends CompositeAttribute
$this
->
attributes
[
0
]
->
setValue
(
$hash
);
$this
->
attributes
[
0
]
->
setDisabled
(
TRUE
);
}
$this
->
checkIfMethodNeedsPassword
();
}
}
...
...
@@ -92,7 +96,37 @@ class UserPasswordAttribute extends CompositeAttribute
$this
->
attributes
[
0
]
->
resetToDefault
();
$this
->
attributes
[
1
]
->
setRequired
(
TRUE
);
$this
->
attributes
[
2
]
->
setRequired
(
TRUE
);
$this
->
checkIfMethodNeedsPassword
();
}
}
function
setValue
(
$value
)
{
parent
::
setValue
(
$value
);
$this
->
checkIfMethodNeedsPassword
();
}
function
applyPostValue
()
{
parent
::
applyPostValue
();
$this
->
checkIfMethodNeedsPassword
();
}
function
checkIfMethodNeedsPassword
()
{
$method
=
$this
->
attributes
[
0
]
->
getValue
();
if
(
$method
!=
$this
->
previousMethod
)
{
if
(
$this
->
needPassword
[
$method
])
{
$this
->
attributes
[
1
]
->
setVisible
(
TRUE
);
$this
->
attributes
[
2
]
->
setVisible
(
TRUE
);
}
else
{
$this
->
attributes
[
1
]
->
setVisible
(
FALSE
);
$this
->
attributes
[
1
]
->
setValue
(
''
);
$this
->
attributes
[
2
]
->
setVisible
(
FALSE
);
$this
->
attributes
[
2
]
->
setValue
(
''
);
}
}
$this
->
previousMethod
=
$method
;
}
function
readValues
(
$value
)
...
...
@@ -115,7 +149,7 @@ class UserPasswordAttribute extends CompositeAttribute
function
writeValues
(
$values
)
{
if
(
$values
[
1
]
==
''
)
{
if
(
$this
->
needPassword
[
$values
[
0
]]
&&
(
$values
[
1
]
==
''
)
)
{
return
$values
[
3
];
}
$temp
=
passwordMethod
::
get_available_methods
();
...
...
@@ -126,6 +160,11 @@ class UserPasswordAttribute extends CompositeAttribute
function
check
()
{
$method
=
$this
->
attributes
[
0
]
->
getValue
();
if
(
!
$this
->
needPassword
[
$method
])
{
$this
->
attributes
[
1
]
->
setRequired
(
FALSE
);
$this
->
attributes
[
2
]
->
setRequired
(
FALSE
);
}
$error
=
parent
::
check
();
if
(
!
empty
(
$error
))
{
return
$error
;
...
...
Côme Chilliet
@cchilliet
mentioned in issue
#808 (closed)
·
Sep 02, 2017
mentioned in issue
#808 (closed)
mentioned in issue #808
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment