-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mail authentication can be set as default (works together with LDAP auth) #18807
base: main
Are you sure you want to change the base?
Conversation
* | ||
* @return AuthMail|AuthLDAP|null Auth ID or null if not found | ||
*/ | ||
public static function getDefaultAuth(): AuthMail|AuthLDAP|null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method should probably be moved in the Auth
class itself.
src/AuthLDAP.php
Outdated
*/ | ||
public static function getDefault() | ||
{ | ||
// @todo trigger deprecation ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is how to trigger a deprecation message in GLPI.
// @todo trigger deprecation ? | |
Toolbox::deprecated('The `AuthLDAP::getDefault()` method is deprecated, use `class::method()` instead.'); |
|
||
if (isset($this->fields['is_default']) && (int) $this->fields["is_default"] === 1) { | ||
// remove from authmails tables | ||
$DB->update( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you copied the existing code, but we should avoid using low level methods directly to update an item, as they prevent plugins hooks to be able to handle the corresponding operations. You should replace DBmysql::update()
by CommonDBTM::update()
here. It requires some refactoring, as you will have first to fetch the existing default server, if any, and the update it.
Same remark for the AuthMail
update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:/ It doesn't look like CommonDBTM::update() give the ability to update multiple items with a where
criteria.
Co-authored-by: Cédric Anne <[email protected]>
Co-authored-by: Cédric Anne <[email protected]>
Co-authored-by: Cédric Anne <[email protected]>
c64df6f
to
5098c81
Compare
Checklist before requesting a review
Please delete options that are not relevant.
Description
Review
It's current a WIP PR.
It does the job but some things may require changes or at least some feedback, for me as glpi new contributor. These are marked with
@todo
annotations in the code.By the way I used another way to write test :
assert()
which also trigger failure if needed but do not count as test. I also help to distinguish between real test assertion failures and test preparation failures. I think this is the way we are supposed to write assertion.