-
Notifications
You must be signed in to change notification settings - Fork 14
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
add email & group query support #26
base: master
Are you sure you want to change the base?
Conversation
add group support (closes PanCakeConnaisseur#7)
Any chance to get this in the main dist? |
+1 |
Works fine for me |
@@ -135,6 +141,8 @@ public function getDisplayName($providedUsername) { | |||
$statement = $this->db->getDbHandle()->prepare($this->config->getQueryGetDisplayName()); | |||
$statement->execute(['username' => $providedUsername]); | |||
$retrievedDisplayName = $statement->fetchColumn(); | |||
|
|||
$this->updateAttributes($providedUsername); |
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.
Any particular reason why attributes are updated in getDisplayName()
?
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.
Thanks @PanCakeConnaisseur for picking this up.
It is already a while ago, so I am not 100% sure why I have put it at that specific place, but I assume I didn't find a better place to trigger the update of the attributes. Where would you suggest to put it?
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 makes more sense to update the attributes whenever it is requested. The way you implemented it, each time a display name is read (which might be often), you update the attributes. This is firstly probably very inefficient and secondly might lead to unexpected behaviour.
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 think the problem was that by only relying on the "whenever it is requested", it got requested too seldom and the only way to make it update it more often was to call it from the getDisplayName()
. Whereas the updateAttributes()
function only updates the attributes if there is really a change, so to prevent the database being updated all the time.
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 went through the code (Nextcloud's) that is calling the user backend and the problem is that setting an email by a user backend is not supported in Nextcloud. There is also no clean way to inject the e-mail at a different point, AFAICS. I thought about adding something to createUser()
to set the e-mail initially but at that stage the user object has not been created yet. I would need to do it later, without getting called explicitly, i.e. store state. This is means there is no clean solution.
You circumvented this limitation by using getDisplayName()
to just overwrite the e-mail field if necessary. I don't agree with that solution because it mixes up reading and writing data and is unexpected behavior. I think a trigger that listens for the "created user" event would be a better solution to set the e-mail initially and then allow the user to change the e-mail. Always overwriting the e-mail like you suggested, feels like a hack to me. I understand that it does the job, but this would be better located in an an extra app. IMHO, the user backend should not have any additional logic that corrects or circumvents the behavior of Nextcloud.
I am currently trying to get in contact with core Nexcloud devs to suggest an overhaul of the user interfaces that would allow a clean solution. Until then, I don't think I will implement an e-mail from/to SQL solution.
Hey kosli, thank you very much for the pull request. I only now have time to work extensively on this app and I am currently evaluating this. |
@kosli thank you very much for your work! Hope this makes it into the next release. |
@PanCakeConnaisseur any update on this pull request? |
@kosli AFAIK there is no progress on the Nextcloud user backend front, therefore the block is still present. I currently don't have the time to push for it or investigate it further. There wasn't much enthusiasm for my architecture draft but nobody provided any alternative. |
@PanCakeConnaisseur Thanks for your feedback and really sad that this hasn't been improved on Nextcloud side. Strange that no other user backends have run into the same issue. |
…ackend_sql_raw into PanCakeConnaisseur-master
Any news on this? The GUI user_sql app somehow does email and groups, but it is otherwise to limited. |
I have implemented the two features:
I am using the app in addition to the user saml app, so I need to update the user information from another database that I have. The user information is updated via the updateAttributes function (similar as in the user saml app) which is triggered via the userExists function -> it may be called quite often, so maybe there is a better place to run it from.