@@ -120,17 +120,15 @@ protected function syncModelFromAdldap(User $user, Authenticatable $model)
120120 */
121121 protected function syncModelPassword (Authenticatable $ model , $ password )
122122 {
123- if ($ model instanceof Model && $ model ->hasSetMutator ('password ' )) {
124- // If the model has a set mutator for the password then
125- // we'll assume that the dev is using their
126- // own encryption method for passwords.
127- $ model ->password = $ password ;
123+ // If the developer doesn't want to synchronize AD passwords,
124+ // we'll set the password to a random 16 character string.
125+ $ password = ($ this ->getPasswordSync () ? $ password : str_random ());
128126
129- return $ model ;
130- }
131-
132- // Always encrypt the model password by default .
133- $ model ->password = bcrypt ($ password );
127+ // If the model has a set mutator for the password then
128+ // we'll assume that the dev is using their own
129+ // encryption method for passwords. Otherwise
130+ // we'll bcrypt it normally .
131+ $ model ->password = ( $ model -> hasSetMutator ( ' password ' ) ? $ password : bcrypt ($ password) );
134132
135133 return $ model ;
136134 }
@@ -246,7 +244,7 @@ protected function getAdldap($provider = null)
246244 }
247245
248246 /**
249- * Retrieves the Aldldap select attributes when performing
247+ * Returns the configured select attributes when performing
250248 * queries for authentication and binding for users.
251249 *
252250 * @return array
@@ -257,7 +255,7 @@ protected function getSelectAttributes()
257255 }
258256
259257 /**
260- * Returns the username attribute for discovering LDAP users.
258+ * Returns the configured username attribute for discovering LDAP users.
261259 *
262260 * @return array
263261 */
@@ -267,7 +265,7 @@ protected function getUsernameAttribute()
267265 }
268266
269267 /**
270- * Retrieves the Adldap bind user to model config option for binding
268+ * Returns the configured bind user to model option for binding
271269 * the Adldap user model instance to the laravel model.
272270 *
273271 * @return bool
@@ -278,7 +276,7 @@ protected function getBindUserToModel()
278276 }
279277
280278 /**
281- * Retrieves the Adldap login attribute for authenticating users.
279+ * Returns the configured login attribute for authenticating users.
282280 *
283281 * @return string
284282 */
@@ -288,7 +286,7 @@ protected function getLoginAttribute()
288286 }
289287
290288 /**
291- * Retrieves the Adldap sync attributes for filling the
289+ * Returns the configured sync attributes for filling the
292290 * Laravel user model with active directory fields.
293291 *
294292 * @return array
@@ -298,6 +296,16 @@ protected function getSyncAttributes()
298296 return Config::get ('adldap_auth.sync_attributes ' , ['name ' => $ this ->getSchema ()->commonName ()]);
299297 }
300298
299+ /**
300+ * Returns the configured password sync configuration option.
301+ *
302+ * @return bool
303+ */
304+ protected function getPasswordSync ()
305+ {
306+ return Config::get ('adldap_auth.password_sync ' , true );
307+ }
308+
301309 /**
302310 * Returns the configured login limitation filter.
303311 *
@@ -309,7 +317,7 @@ protected function getLimitationFilter()
309317 }
310318
311319 /**
312- * Retrieves the default connection name from the configuration .
320+ * Returns the configured default connection name.
313321 *
314322 * @return mixed
315323 */
0 commit comments