mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-06 10:44:33 +08:00
Made social accounts attachable
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
|
||||
namespace Oxbow\Http\Controllers\Auth;
|
||||
|
||||
use Oxbow\Exceptions\UserNotFound;
|
||||
use Oxbow\Exceptions\SocialSignInException;
|
||||
use Oxbow\Services\SocialAuthService;
|
||||
use Oxbow\User;
|
||||
use Validator;
|
||||
@ -37,7 +37,7 @@ class AuthController extends Controller
|
||||
*/
|
||||
public function __construct(SocialAuthService $socialAuthService)
|
||||
{
|
||||
$this->middleware('guest', ['except' => 'getLogout']);
|
||||
$this->middleware('guest', ['only' => ['getLogin', 'postLogin']]);
|
||||
$this->socialAuthService = $socialAuthService;
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ class AuthController extends Controller
|
||||
*/
|
||||
public function getSocialLogin($socialDriver)
|
||||
{
|
||||
return $this->socialAuthService->logIn($socialDriver);
|
||||
return $this->socialAuthService->startLogIn($socialDriver);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,13 +103,21 @@ class AuthController extends Controller
|
||||
*
|
||||
* @param $socialDriver
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws UserNotFound
|
||||
* @throws SocialSignInException
|
||||
*/
|
||||
public function socialCallback($socialDriver)
|
||||
{
|
||||
$user = $this->socialAuthService->getUserFromCallback($socialDriver);
|
||||
\Auth::login($user, true);
|
||||
return redirect($this->redirectPath);
|
||||
return $this->socialAuthService->handleCallback($socialDriver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detach a social account from a user.
|
||||
* @param $socialDriver
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
public function detachSocialAccount($socialDriver)
|
||||
{
|
||||
return $this->socialAuthService->detachSocialAccount($socialDriver);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ use Illuminate\Http\Request;
|
||||
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Oxbow\Http\Requests;
|
||||
use Oxbow\Services\SocialAuthService;
|
||||
use Oxbow\User;
|
||||
|
||||
class UserController extends Controller
|
||||
@ -74,16 +75,19 @@ class UserController extends Controller
|
||||
/**
|
||||
* Show the form for editing the specified user.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @param SocialAuthService $socialAuthService
|
||||
* @return Response
|
||||
*/
|
||||
public function edit($id)
|
||||
public function edit($id, SocialAuthService $socialAuthService)
|
||||
{
|
||||
$this->checkPermissionOr('user-update', function () use ($id) {
|
||||
return $this->currentUser->id == $id;
|
||||
});
|
||||
|
||||
$user = $this->user->findOrFail($id);
|
||||
return view('users/edit', ['user' => $user]);
|
||||
$activeSocialDrivers = $socialAuthService->getActiveDrivers();
|
||||
return view('users/edit', ['user' => $user, 'activeSocialDrivers' => $activeSocialDrivers]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,13 +111,14 @@ class UserController extends Controller
|
||||
]);
|
||||
|
||||
$user = $this->user->findOrFail($id);
|
||||
$user->fill($request->all());
|
||||
$user->fill($request->except('password'));
|
||||
|
||||
if ($this->currentUser->can('user-update') && $request->has('role')) {
|
||||
$user->attachRoleId($request->get('role'));
|
||||
}
|
||||
|
||||
if ($request->has('password') && $request->get('password') != '') {
|
||||
//dd('cat');
|
||||
$password = $request->get('password');
|
||||
$user->password = Hash::make($password);
|
||||
}
|
||||
|
Reference in New Issue
Block a user