File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
lib/private/Authentication/Login
tests/lib/Authentication/Login Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -38,9 +38,21 @@ public function __construct(IUserManager $userManager) {
3838
3939 public function process (LoginData $ loginData ): LoginResult {
4040 if ($ loginData ->getUser () === false ) {
41+ if (!filter_var ($ loginData ->getUsername (), FILTER_VALIDATE_EMAIL )) {
42+ return $ this ->processNextOrFinishSuccessfully ($ loginData );
43+ }
44+
4145 $ users = $ this ->userManager ->getByEmail ($ loginData ->getUsername ());
4246 // we only allow login by email if unique
4347 if (count ($ users ) === 1 ) {
48+
49+ // FIXME: This is a workaround to still stick to configured LDAP login filters
50+ // this can be removed once the email login is properly implemented in the local user backend
51+ // as described in https://github.com/nextcloud/server/issues/5221
52+ if ($ users [0 ]->getBackendClassName () === 'LDAP ' ) {
53+ return $ this ->processNextOrFinishSuccessfully ($ loginData );
54+ }
55+
4456 $ username = $ users [0 ]->getUID ();
4557 if ($ username !== $ loginData ->getUsername ()) {
4658 $ user = $ this ->userManager ->checkPassword (
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ public function testProcessAlreadyLoggedIn() {
5555
5656 public function testProcessNotAnEmailLogin () {
5757 $ data = $ this ->getFailedLoginData ();
58- $ this ->userManager ->expects ($ this ->once ())
58+ $ this ->userManager ->expects ($ this ->never ())
5959 ->method ('getByEmail ' )
6060 ->with ($ this ->username )
6161 ->willReturn ([]);
@@ -67,9 +67,10 @@ public function testProcessNotAnEmailLogin() {
6767
6868 public function testProcessDuplicateEmailLogin () {
6969 $ data = $ this ->getFailedLoginData ();
70+ $ data->
setUsername (
'[email protected] ' );
7071 $ this ->userManager ->expects ($ this ->once ())
7172 ->method ('getByEmail ' )
72- ->with ($ this -> username )
73+ 7374 ->willReturn ([
7475 $ this ->createMock (IUser::class),
7576 $ this ->createMock (IUser::class),
You can’t perform that action at this time.
0 commit comments