-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Started move to laravel 5.3 * Started updating login & registration flows for laravel 5.3 update * Updated app emails to notification system * Fixed registations bugs and removed email confirmation model * Fixed large portion of laravel post-upgrade issues * Fixed and tested LDAP process
- Loading branch information
1 parent
393f604
commit 9dc9724
Showing
44 changed files
with
1,789 additions
and
1,100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace BookStack\Http\Controllers\Auth; | ||
|
||
use BookStack\Http\Controllers\Controller; | ||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails; | ||
|
||
class ForgotPasswordController extends Controller | ||
{ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Password Reset Controller | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This controller is responsible for handling password reset emails and | ||
| includes a trait which assists in sending these notifications from | ||
| your application to your users. Feel free to explore this trait. | ||
| | ||
*/ | ||
|
||
use SendsPasswordResetEmails; | ||
|
||
/** | ||
* Create a new controller instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->middleware('guest'); | ||
parent::__construct(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<?php | ||
|
||
namespace BookStack\Http\Controllers\Auth; | ||
|
||
use BookStack\Http\Controllers\Controller; | ||
use BookStack\Repos\UserRepo; | ||
use BookStack\Services\SocialAuthService; | ||
use Illuminate\Contracts\Auth\Authenticatable; | ||
use Illuminate\Foundation\Auth\AuthenticatesUsers; | ||
use Illuminate\Http\Request; | ||
|
||
class LoginController extends Controller | ||
{ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Login Controller | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This controller handles authenticating users for the application and | ||
| redirecting them to your home screen. The controller uses a trait | ||
| to conveniently provide its functionality to your applications. | ||
| | ||
*/ | ||
|
||
use AuthenticatesUsers; | ||
|
||
/** | ||
* Where to redirect users after login. | ||
* | ||
* @var string | ||
*/ | ||
protected $redirectTo = '/'; | ||
|
||
protected $redirectPath = '/'; | ||
protected $redirectAfterLogout = '/login'; | ||
|
||
protected $socialAuthService; | ||
protected $userRepo; | ||
|
||
/** | ||
* Create a new controller instance. | ||
* | ||
* @param SocialAuthService $socialAuthService | ||
* @param UserRepo $userRepo | ||
*/ | ||
public function __construct(SocialAuthService $socialAuthService, UserRepo $userRepo) | ||
{ | ||
$this->middleware('guest', ['only' => ['getLogin', 'postLogin']]); | ||
$this->socialAuthService = $socialAuthService; | ||
$this->userRepo = $userRepo; | ||
$this->redirectPath = baseUrl('/'); | ||
$this->redirectAfterLogout = baseUrl('/login'); | ||
parent::__construct(); | ||
} | ||
|
||
public function username() | ||
{ | ||
return config('auth.method') === 'standard' ? 'email' : 'username'; | ||
} | ||
|
||
/** | ||
* Overrides the action when a user is authenticated. | ||
* If the user authenticated but does not exist in the user table we create them. | ||
* @param Request $request | ||
* @param Authenticatable $user | ||
* @return \Illuminate\Http\RedirectResponse | ||
* @throws AuthException | ||
*/ | ||
protected function authenticated(Request $request, Authenticatable $user) | ||
{ | ||
// Explicitly log them out for now if they do no exist. | ||
if (!$user->exists) auth()->logout($user); | ||
|
||
if (!$user->exists && $user->email === null && !$request->has('email')) { | ||
$request->flash(); | ||
session()->flash('request-email', true); | ||
return redirect('/login'); | ||
} | ||
|
||
if (!$user->exists && $user->email === null && $request->has('email')) { | ||
$user->email = $request->get('email'); | ||
} | ||
|
||
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(); | ||
$this->userRepo->attachDefaultRole($user); | ||
auth()->login($user); | ||
} | ||
|
||
$path = session()->pull('url.intended', '/'); | ||
$path = baseUrl($path, true); | ||
return redirect($path); | ||
} | ||
|
||
/** | ||
* Show the application login form. | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function getLogin() | ||
{ | ||
$socialDrivers = $this->socialAuthService->getActiveDrivers(); | ||
$authMethod = config('auth.method'); | ||
return view('auth/login', ['socialDrivers' => $socialDrivers, 'authMethod' => $authMethod]); | ||
} | ||
|
||
/** | ||
* Redirect to the relevant social site. | ||
* @param $socialDriver | ||
* @return \Symfony\Component\HttpFoundation\RedirectResponse | ||
*/ | ||
public function getSocialLogin($socialDriver) | ||
{ | ||
session()->put('social-callback', 'login'); | ||
return $this->socialAuthService->startLogIn($socialDriver); | ||
} | ||
} |
Oops, something went wrong.