Pass the password along directly instead of retrieving it from the Input or Request

This commit is contained in:
Brady Wetherington 2022-05-16 10:58:27 -07:00
parent 93e509bd79
commit 6c86a28d18
2 changed files with 4 additions and 3 deletions

View file

@ -185,7 +185,7 @@ class LoginController extends Controller
Log::debug("Local user ".$request->input('username')." does not exist");
Log::debug("Creating local user ".$request->input('username'));
if ($user = Ldap::createUserFromLdap($ldap_user)) { //this handles passwords on its own
if ($user = Ldap::createUserFromLdap($ldap_user, $request->input('password'))) {
Log::debug("Local user created.");
} else {
Log::debug("Could not create local user.");

View file

@ -233,7 +233,7 @@ class Ldap extends Model
* @param $ldapatttibutes
* @return array|bool
*/
public static function createUserFromLdap($ldapatttibutes)
public static function createUserFromLdap($ldapatttibutes, $password)
{
$item = self::parseAndMapLdapAttributes($ldapatttibutes);
@ -246,7 +246,8 @@ class Ldap extends Model
$user->email = $item['email'];
if (Setting::getSettings()->ldap_pw_sync == '1') {
$user->password = bcrypt(Input::get('password'));
$user->password = bcrypt($password);
} else {
$pass = substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 25);
$user->password = bcrypt($pass);