mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-28 21:22:30 +00:00
Made email confirmations work with LDAP auth
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.
This commit is contained in:
parent
4caa61fe96
commit
2bb8c3d914
@ -194,14 +194,11 @@ class AuthController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (setting('registration-confirmation') || setting('registration-restrict')) {
|
if (setting('registration-confirmation') || setting('registration-restrict')) {
|
||||||
$newUser->email_confirmed = false;
|
|
||||||
$newUser->save();
|
$newUser->save();
|
||||||
$this->emailConfirmationService->sendConfirmation($newUser);
|
$this->emailConfirmationService->sendConfirmation($newUser);
|
||||||
return redirect('/register/confirm');
|
return redirect('/register/confirm');
|
||||||
}
|
}
|
||||||
|
|
||||||
$newUser->email_confirmed = true;
|
|
||||||
|
|
||||||
auth()->login($newUser);
|
auth()->login($newUser);
|
||||||
session()->flash('success', 'Thanks for signing up! You are now registered and signed in.');
|
session()->flash('success', 'Thanks for signing up! You are now registered and signed in.');
|
||||||
return redirect($this->redirectPath());
|
return redirect($this->redirectPath());
|
||||||
|
@ -11,14 +11,12 @@ class Authenticate
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The Guard implementation.
|
* The Guard implementation.
|
||||||
*
|
|
||||||
* @var Guard
|
* @var Guard
|
||||||
*/
|
*/
|
||||||
protected $auth;
|
protected $auth;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new filter instance.
|
* Create a new filter instance.
|
||||||
*
|
|
||||||
* @param Guard $auth
|
* @param Guard $auth
|
||||||
*/
|
*/
|
||||||
public function __construct(Guard $auth)
|
public function __construct(Guard $auth)
|
||||||
@ -28,14 +26,13 @@ class Authenticate
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle an incoming request.
|
* Handle an incoming request.
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @param \Closure $next
|
* @param \Closure $next
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function handle($request, Closure $next)
|
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');
|
return redirect()->guest('/register/confirm/awaiting');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ class LdapUserProvider implements UserProvider
|
|||||||
$model->name = $userDetails['name'];
|
$model->name = $userDetails['name'];
|
||||||
$model->external_auth_id = $userDetails['uid'];
|
$model->external_auth_id = $userDetails['uid'];
|
||||||
$model->email = $userDetails['email'];
|
$model->email = $userDetails['email'];
|
||||||
$model->email_confirmed = true;
|
$model->email_confirmed = false;
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,8 @@ class UserRepo
|
|||||||
return $this->user->forceCreate([
|
return $this->user->forceCreate([
|
||||||
'name' => $data['name'],
|
'name' => $data['name'],
|
||||||
'email' => $data['email'],
|
'email' => $data['email'],
|
||||||
'password' => bcrypt($data['password'])
|
'password' => bcrypt($data['password']),
|
||||||
|
'email_confirmed' => false
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user