mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Added a friendlier error for LDAP new user mismatches
This commit is contained in:
parent
c5960f9b6a
commit
4caa61fe96
4
app/Exceptions/AuthException.php
Normal file
4
app/Exceptions/AuthException.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?php namespace BookStack\Exceptions;
|
||||||
|
|
||||||
|
|
||||||
|
class AuthException extends PrettyException {}
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace BookStack\Http\Controllers\Auth;
|
namespace BookStack\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use BookStack\Exceptions\AuthException;
|
||||||
|
use BookStack\Exceptions\PrettyException;
|
||||||
use Illuminate\Contracts\Auth\Authenticatable;
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use BookStack\Exceptions\SocialSignInException;
|
use BookStack\Exceptions\SocialSignInException;
|
||||||
@ -115,6 +117,7 @@ class AuthController extends Controller
|
|||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Authenticatable $user
|
* @param Authenticatable $user
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
* @throws AuthException
|
||||||
*/
|
*/
|
||||||
protected function authenticated(Request $request, Authenticatable $user)
|
protected function authenticated(Request $request, Authenticatable $user)
|
||||||
{
|
{
|
||||||
@ -132,6 +135,13 @@ class AuthController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$user->exists) {
|
if (!$user->exists) {
|
||||||
|
|
||||||
|
// Check for users with same email already
|
||||||
|
$alreadyUser = $user->newQuery()->where('email', '=', $user->email)->count() > 0;
|
||||||
|
if ($alreadyUser) {
|
||||||
|
throw new AuthException('A user with the email ' . $user->email . ' already exists but with different credentials.');
|
||||||
|
}
|
||||||
|
|
||||||
$user->save();
|
$user->save();
|
||||||
$this->userRepo->attachDefaultRole($user);
|
$this->userRepo->attachDefaultRole($user);
|
||||||
auth()->login($user);
|
auth()->login($user);
|
||||||
|
Loading…
Reference in New Issue
Block a user