]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/UserController.php
Updated user interfaces for LDAP and added email from LDAP
[bookstack] / app / Http / Controllers / UserController.php
index 9184b245ef29c0324de3f397c735b4ca346d4042..f504f447734c77d242c9146d536ce99f60d518e9 100644 (file)
@@ -46,7 +46,8 @@ class UserController extends Controller
     public function create()
     {
         $this->checkPermission('user-create');
-        return view('users/create');
+        $authMethod = config('auth.method');
+        return view('users/create', ['authMethod' => $authMethod]);
     }
 
     /**
@@ -94,10 +95,12 @@ class UserController extends Controller
             return $this->currentUser->id == $id;
         });
 
+        $authMethod = config('auth.method');
+
         $user = $this->user->findOrFail($id);
         $activeSocialDrivers = $socialAuthService->getActiveDrivers();
         $this->setPageTitle('User Profile');
-        return view('users/edit', ['user' => $user, 'activeSocialDrivers' => $activeSocialDrivers]);
+        return view('users/edit', ['user' => $user, 'activeSocialDrivers' => $activeSocialDrivers, 'authMethod' => $authMethod]);
     }
 
     /**
@@ -124,17 +127,24 @@ class UserController extends Controller
         ]);
 
         $user = $this->user->findOrFail($id);
-        $user->fill($request->except('password'));
+        $user->fill($request->all());
 
+        // Role updates
         if ($this->currentUser->can('user-update') && $request->has('role')) {
             $user->attachRoleId($request->get('role'));
         }
 
+        // Password updates
         if ($request->has('password') && $request->get('password') != '') {
             $password = $request->get('password');
             $user->password = bcrypt($password);
         }
 
+        // External auth id updates
+        if ($this->currentUser->can('user-update') && $request->has('external_auth_id')) {
+            $user->external_auth_id = $request->get('external_auth_id');
+        }
+
         $user->save();
         return redirect('/users');
     }