Skip to content

A free open source IT asset/license management system

Ignore location field if no value is passed

snipe3b247ba31fcc
diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php
index 38eca97985..691c158fad 100755
--- a/app/Http/Controllers/UsersController.php
+++ b/app/Http/Controllers/UsersController.php
@@ -1149,7 +1149,6 @@ class UsersController extends Controller
protected $ldapValidationRules = array(
'firstname' => 'required|string|min:2',
- 'lastname' => 'required|string|min:2',
'employee_number' => 'string',
'username' => 'required|min:2|unique:users,username',
'email' => 'email|unique:users,email',
@@ -1162,7 +1161,7 @@ class UsersController extends Controller
* @since [v1.8]
* @return Redirect
*/
- public function postLDAP()
+ public function postLDAP(Request $request)
{
ini_set('max_execution_time', 600); //600 seconds = 10 minutes
ini_set('memory_limit', '500M');
@@ -1175,9 +1174,6 @@ class UsersController extends Controller
$ldap_result_emp_num = Setting::getSettings()->ldap_emp_num;
$ldap_result_email = Setting::getSettings()->ldap_email;
-
- $location_id = e(Input::get('location_id'));
-
try {
$ldapconn = Ldap::connectToLdap();
} catch (\Exception $e) {
@@ -1225,7 +1221,9 @@ class UsersController extends Controller
$user->email = e($item["email"]);
$user->employee_num = e($item["employee_number"]);
$user->activated = 1;
- $user->location_id = e($location_id);
+ if ($request->has('location_id')) {
+ $user->location_id = e($request->input('location_id'));
+ }
$user->notes = 'Imported from LDAP';
$user->ldap_import = 1;