-
Notifications
You must be signed in to change notification settings - Fork 71
occ check-code compliance #30
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
Conversation
|
@MorrisJobke @rullzer @nickvergessen could someone help me with these two points? |
Go with a OCP\DB\IController instead ;) |
Signed-off-by: Jonas Sulzer <jonas@violoncello.ch>
Signed-off-by: Jonas Sulzer <jonas@violoncello.ch>
Signed-off-by: Jonas Sulzer <jonas@violoncello.ch>
a99e0b2 to
4eea136
Compare
Signed-off-by: Jonas Sulzer <jonas@violoncello.ch>
|
So what would be your suggestion @nickvergessen ? (as you reacted on #30 (comment)) |
|
Ah, sorry to create confusion. The interface name was wrong: |
Yes - it was late and I mixed up the terms :/ @nickvergessen is right 👍 |
|
thank you for the clarification! but this fails with |
|
For now use |
|
thank you @nickvergessen this worked in three places! Lines 58 to 62 in 05fb0e2
Lines 77 to 86 in 05fb0e2
Lines 173 to 178 in 05fb0e2
what can I use there? |
|
Can you push your changes here? Then I will have a look |
Signed-off-by: Jonas Sulzer <jonas@violoncello.ch>
|
I pushed the changes for where |
|
You should be able to change those calls from |
…) where possible Signed-off-by: Jonas Sulzer <jonas@violoncello.ch>
|
thank you! I changed this, where it worked for me this way. However there are still to places where this fails; these are the functions in which it fails: Line 76 in 05fb0e2
Line 101 in 05fb0e2
it fails on the second one on loading the user list (if a user from user_external should be loaded) and errors with: |
|
Ah, opsy $result = OC_DB::executeAudited(
array(
'sql' => 'SELECT `uid`, `displayname` FROM `*PREFIX*users_external`'
. ' WHERE (LOWER(`displayname`) LIKE LOWER(?) '
. ' OR LOWER(`uid`) LIKE LOWER(?)) AND `backend` = ?',
'limit' => $limit,
'offset' => $offset
),
array('%' . $search . '%', '%' . $search . '%', $this->backend)
);
$displayNames = array();
while ($row = $result->fetchRow()) {
$displayNames[$row['uid']] = $row['displayname'];
}to $stmt = \OC::$server->getDatabaseConnection()->prepare(
'SELECT `uid`, `displayname` FROM `*PREFIX*users_external`'
. ' WHERE (LOWER(`displayname`) LIKE LOWER(?) '
. ' OR LOWER(`uid`) LIKE LOWER(?)) AND `backend` = ?',
$limit, $offset
);
$stmt->execute(['%' . $search . '%', '%' . $search . '%', $this->backend]);
$displayNames = array();
while ($row = $stmt->fetch()) {
$displayNames[$row['uid']] = $row['displayname'];
}and similar for the second one. |
…remaining two Signed-off-by: Jonas Sulzer <jonas@violoncello.ch>
|
thank you very much @nickvergessen ! This is now finally completely working! remains my first question (for this to be complete):
|
Signed-off-by: Joas Schilling <coding@schilljs.com>
|
fixed |
|
ahh, that simply needs to be after "author"... thanks! |
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/imap.php
Outdated
| // Check if we only want logins from ONE domain and strip the domain part from UID | ||
| }elseif($this->domain != '') { | ||
| // Check if we only want logins from ONE domain and strip the domain part from UID | ||
| }elseif($this->domain !== '') { |
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 code is really strange, when there is not exactly one user, the database result is being ignored. Is this intended?
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.
hmm, maybe @kosli can help us here?
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.
or maybe @pierreozoux ?
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.
@nickvergessen the database returns as many users as there are with the same email address (if this emailaddress is entered in the login form), so this should be zero or one normally, shouldn't it?
It makes it possible to login for normal users with their email address even though in config.php for imap backend another domain is specified. This code as it is written now wouldn't work if there are multiple users with the same email address anyway. If we would change it to if(count($users) >= 1) it would always try to login the first user with the given email address... so I think it's better leave it as it is now and not to try to log in the user at all, if the email address is assigned to multiple users. How does Nextcloud's own user backend handle this case? Shouldn't it be restricted that only one user can have a specific email address?
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.
If there are more than 2 users you can not login with email:
https://github.com/nextcloud/server/blob/43d6ae7476bbf4d08991b405a63a0f8dbc2ac25a/core/Controller/LoginController.php#L311-L312
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 don't suggest to use if(count($users) >= 1), I just wanted to know if that is intended behaviour. Also as per the code I liked above, the imap user backend should not need to do this. It will be done by the user manager. So actually this method (checkPassword) will be called twice already for email alike logins, so the user_external app does not need to check this.
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 commited accordingly, if you still want to keep this, just rebase and drop the commit
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.
okay, thank you for clarifying! I'm fine with removing it; login with email for a normal user with another domain still works...
Signed-off-by: Joas Schilling <coding@schilljs.com>
as of #6
static method of private class must not be calledandprivate class must not be imported with a use statementcc @nextcloud/user_external
occ check-code says for the appinfo.xml that the element
typeswould not be expected. In NC12 documentation I can findtypes, in any newer version it's gone and I can't find any information with what I could replace / change this.I would also need help with
OC_DB - private class must not be imported with a use statementandOC_DB - Static method of private class must not be called. What has to be changed there?