Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

kosli
Copy link

@kosli kosli commented Apr 8, 2020

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.

@a-schild
Copy link

Any chance to get this in the main dist?
The support for groups is realy interesting for us

@oucil
Copy link

oucil commented Jun 2, 2020

+1

@GMo7944
Copy link

GMo7944 commented Jun 19, 2020

Works fine for me
Thanks a lot

@@ -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);

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()?

Copy link
Author

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?

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.

Copy link
Author

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.

Copy link
Owner

@PanCakeConnaisseur PanCakeConnaisseur Oct 11, 2020

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.

@PanCakeConnaisseur
Copy link
Owner

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.

@funbotan
Copy link

funbotan commented Oct 5, 2021

@kosli thank you very much for your work! Hope this makes it into the next release.

@kosli
Copy link
Author

kosli commented Apr 27, 2022

@PanCakeConnaisseur any update on this pull request?

@PanCakeConnaisseur
Copy link
Owner

@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.

@kosli
Copy link
Author

kosli commented May 31, 2022

@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.

@poVoq
Copy link

poVoq commented Sep 11, 2022

Any news on this? The GUI user_sql app somehow does email and groups, but it is otherwise to limited.

@kosli kosli mentioned this pull request Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add email query support Add group support
7 participants