@@ -86,9 +86,7 @@ protected function retrieveAuthenticatedUser($key, $username)
8686 $ resolver = $ this ->getResolver ();
8787
8888 // Find the user in AD.
89- $ user = $ resolver ->query ()
90- ->where ([$ key => $ username ])
91- ->firstOrFail ();
89+ $ user = $ resolver ->query ()->where ([$ key => $ username ])->firstOrFail ();
9290
9391 if ($ provider instanceof NoDatabaseUserProvider) {
9492 $ this ->handleAuthenticatedWithWindows ($ user );
@@ -99,12 +97,14 @@ protected function retrieveAuthenticatedUser($key, $username)
9997 $ resolver ->getEloquentUsername () => $ user ->getFirstAttribute ($ resolver ->getLdapUsername ()),
10098 ];
10199
102- // Retrieve the Eloquent user model from our AD user instance.
103- // We'll assign the user a random password since we don't
104- // have access to it through SSO auth.
100+ // Here we'll import the AD user. If the user already exists in our local
101+ // database, it will be returned from the importer. We also won't pass
102+ // in any password key into the credentials array so the importer
103+ // assigns a random 16 character password for us.
105104 $ model = $ this ->getImporter ()->run ($ user , $ this ->getModel (), $ credentials );
106105
107- // Save model in case of changes.
106+ // We also want to save the returned model in case it doesn't
107+ // exist yet, or there are changes to be synced.
108108 $ model ->save ();
109109
110110 $ this ->handleAuthenticatedWithWindows ($ user , $ model );
0 commit comments