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

fix: Move login via email logic to local backend #47686

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Sep 2, 2024

Summary

Backends can decide which names they accept for login, e.g. with user_ldap you can configure arbitrary login fields. This was a hacky approach to allow login via email, so instead this is now only handled by the local user backend.

This also fixes some other related problems:
Other logic relys on backend::get() which was not handling email, so e.g. password policy could not block users logged in via email if they use out-dated passwords.
Similar for other integrations, as the user backend was not consistent with what is a login name and what not.

Checklist

Backends can decide which names they accept for login,
e.g. with user_ldap you can configure arbitrary login fields.
This was a hacky approach to allow login via email,
so instead this is now only handled by the local user backend.

This also fixes some other related problems:
Other logic relys on `backend::get()` which was not handling email,
so e.g. password policy could not block users logged in via email
if they use out-dated passwords.
Similar for other integrations, as the user backend was not consistent with
what is a login name and what not.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@susnux susnux added feature: users and groups technical debt php Pull requests that update Php code 2. developing Work in progress labels Sep 2, 2024
@susnux susnux added this to the Nextcloud 31 milestone Sep 2, 2024
private function loadUser($uid) {
$this->fixDI();
private function loadUser(string $loginName, bool $tryEmail = true): bool {
$uid = (string)$loginName;

Check failure

Code scanning / Psalm

RedundantCast Error

Redundant cast to string
if ($result) {
// Also add cache result for the email
$this->cache[$uid] = [
...$this->cache[$emailUId],

Check failure

Code scanning / Psalm

InvalidOperand Error

Cannot use spread operator on non-iterable type mixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress feature: users and groups php Pull requests that update Php code technical debt
Projects
None yet
1 participant