]> BookStack Code Mirror - bookstack/commitdiff
Made email confirmations work with LDAP auth
authorDan Brown <redacted>
Sun, 3 Apr 2016 11:16:54 +0000 (12:16 +0100)
committerDan Brown <redacted>
Sun, 3 Apr 2016 11:16:54 +0000 (12:16 +0100)
The email_confirmed user field now actually indicates if an email is confirmed rather than defaulting to true if not checked.
 This ensures toggleing the 'Require email confirmation' setting actually makes all currently unconfirmed users confirm thier emails.

app/Http/Controllers/Auth/AuthController.php
app/Http/Middleware/Authenticate.php
app/Providers/LdapUserProvider.php
app/Repos/UserRepo.php

index ef44b2aef9834f62920338c211086223c9cf761e..beb191d624f1841169a17b5467aff9e28c9f3e4d 100644 (file)
@@ -194,14 +194,11 @@ class AuthController extends Controller
         }
 
         if (setting('registration-confirmation') || setting('registration-restrict')) {
-            $newUser->email_confirmed = false;
             $newUser->save();
             $this->emailConfirmationService->sendConfirmation($newUser);
             return redirect('/register/confirm');
         }
 
-        $newUser->email_confirmed = true;
-
         auth()->login($newUser);
         session()->flash('success', 'Thanks for signing up! You are now registered and signed in.');
         return redirect($this->redirectPath());
index 81392fe6e94a152faf290271b95554594aa0e18a..599f40c84a7f61ccf9bf497d152dfb39726a0e81 100644 (file)
@@ -11,14 +11,12 @@ class Authenticate
 {
     /**
      * The Guard implementation.
-     *
      * @var Guard
      */
     protected $auth;
 
     /**
      * Create a new filter instance.
-     *
      * @param  Guard $auth
      */
     public function __construct(Guard $auth)
@@ -28,14 +26,13 @@ class Authenticate
 
     /**
      * Handle an incoming request.
-     *
      * @param  \Illuminate\Http\Request  $request
      * @param  \Closure  $next
      * @return mixed
      */
     public function handle($request, Closure $next)
     {
-        if(auth()->check() && auth()->user()->email_confirmed == false) {
+        if ($this->auth->check() && setting('registration-confirmation') && !$this->auth->user()->email_confirmed) {
             return redirect()->guest('/register/confirm/awaiting');
         }
 
index 30fa739c265803f79af50e1def9b856fdf675a80..a15257aecd96f933f84ff1bfd1981cfbbe3b7e67 100644 (file)
@@ -115,7 +115,7 @@ class LdapUserProvider implements UserProvider
         $model->name = $userDetails['name'];
         $model->external_auth_id = $userDetails['uid'];
         $model->email = $userDetails['email'];
-        $model->email_confirmed = true;
+        $model->email_confirmed = false;
         return $model;
     }
 
index d5a4b1503ccf0735efbfef90f9ad87a47591522d..9b5c8d7e7f20c13816ac421664b54192cb7b187a 100644 (file)
@@ -106,7 +106,8 @@ class UserRepo
         return $this->user->forceCreate([
             'name'     => $data['name'],
             'email'    => $data['email'],
-            'password' => bcrypt($data['password'])
+            'password' => bcrypt($data['password']),
+            'email_confirmed' => false
         ]);
     }