Skip to content

Commit

Permalink
Only bcrypt temp passwords once for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Jul 26, 2016
1 parent eec22c5 commit 261d2f1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/Http/Controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,10 @@ public function postLDAP()

$results = Ldap::findLdapUsers();

$tmp_pass = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20);
$pass = bcrypt($tmp_pass);


for ($i = 0; $i < $results["count"]; $i++) {
if (empty($ldap_result_active_flag) || $results[$i][$ldap_result_active_flag][0] == "TRUE") {

Expand All @@ -1194,19 +1198,18 @@ public function postLDAP()
$item["createorupdate"] = 'updated';
if (!$user = User::where('username', $item["username"])->first()) {
$user = new User;
$user->password = $pass;
$item["createorupdate"] = 'created';
}


// Create the user if they don't exist.
$pass = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20);


$user->first_name = e($item["firstname"]);
$user->last_name = e($item["lastname"]);
$user->username = e($item["username"]);
$user->email = e($item["email"]);
$user->employee_num = e($item["employee_number"]);
$user->password = bcrypt($pass);
$user->activated = 1;
$user->location_id = e($location_id);
$user->notes = 'Imported from LDAP';
Expand Down Expand Up @@ -1234,7 +1237,7 @@ public function postLDAP()



return redirect()->route('ldap/user')->with('success', "OK")->with('summary', $summary);
return redirect()->route('ldap/user')->with('success', "LDAP Import successful.")->with('summary', $summary);
}

/**
Expand Down

0 comments on commit 261d2f1

Please sign in to comment.