]> BookStack Code Mirror - bookstack/commitdiff
Updated register paths to include user slugs
authorDan Brown <redacted>
Wed, 10 Mar 2021 22:37:53 +0000 (22:37 +0000)
committerDan Brown <redacted>
Wed, 10 Mar 2021 22:37:53 +0000 (22:37 +0000)
app/Auth/Access/SocialAuthService.php
app/Auth/UserRepo.php
app/Http/Controllers/Auth/SocialController.php
routes/web.php

index b0383a938522e0ba67cad2213a29895f5d82cba2..df8513a845ed967bf2e2d0136b673ca6ee014418 100644 (file)
@@ -221,7 +221,7 @@ class SocialAuthService
      * Detach a social account from a user.
      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
      */
-    public function detachSocialAccount(string $socialDriver)
+    public function detachSocialAccount(string $socialDriver): void
     {
         user()->socialAccounts()->where('driver', '=', $socialDriver)->delete();
     }
index bcaf9cd0972fd42249213d10371cc85e9ca55a4a..e437ff1e3b367daeba67fca740197a2e5483894f 100644 (file)
@@ -167,7 +167,13 @@ class UserRepo
             'email_confirmed' => $emailConfirmed,
             'external_auth_id' => $data['external_auth_id'] ?? '',
         ];
-        return User::query()->forceCreate($details);
+
+        $user = new User();
+        $user->forceFill($details);
+        $user->refreshSlug();
+        $user->save();
+
+        return $user;
     }
 
     /**
index 0c53c92330b2504cece585772131c3147fa9e566..d4cfe4fe3ea4f79b0b0a325885d19594f6266d41 100644 (file)
@@ -9,9 +9,7 @@ use BookStack\Exceptions\SocialSignInAccountNotUsed;
 use BookStack\Exceptions\SocialSignInException;
 use BookStack\Exceptions\UserRegistrationException;
 use BookStack\Http\Controllers\Controller;
-use Illuminate\Http\RedirectResponse;
 use Illuminate\Http\Request;
-use Illuminate\Routing\Redirector;
 use Illuminate\Support\Str;
 use Laravel\Socialite\Contracts\User as SocialUser;
 
@@ -31,12 +29,11 @@ class SocialController extends Controller
         $this->registrationService = $registrationService;
     }
 
-
     /**
      * Redirect to the relevant social site.
-     * @throws \BookStack\Exceptions\SocialDriverNotConfigured
+     * @throws SocialDriverNotConfigured
      */
-    public function getSocialLogin(string $socialDriver)
+    public function login(string $socialDriver)
     {
         session()->put('social-callback', 'login');
         return $this->socialAuthService->startLogIn($socialDriver);
@@ -47,7 +44,7 @@ class SocialController extends Controller
      * @throws SocialDriverNotConfigured
      * @throws UserRegistrationException
      */
-    public function socialRegister(string $socialDriver)
+    public function register(string $socialDriver)
     {
         $this->registrationService->ensureRegistrationAllowed();
         session()->put('social-callback', 'register');
@@ -60,7 +57,7 @@ class SocialController extends Controller
      * @throws SocialDriverNotConfigured
      * @throws UserRegistrationException
      */
-    public function socialCallback(Request $request, string $socialDriver)
+    public function callback(Request $request, string $socialDriver)
     {
         if (!session()->has('social-callback')) {
             throw new SocialSignInException(trans('errors.social_no_action_defined'), '/login');
@@ -99,7 +96,7 @@ class SocialController extends Controller
     /**
      * Detach a social account from a user.
      */
-    public function detachSocialAccount(string $socialDriver)
+    public function detach(string $socialDriver)
     {
         $this->socialAuthService->detachSocialAccount($socialDriver);
         session()->flash('success', trans('settings.users_social_disconnected', ['socialAccount' => Str::title($socialDriver)]));
index bb772b3dd0050832d522df702da76147fa5986eb..9d482dc41a8e52bfc842eeca7a5cc364b759d44e 100644 (file)
@@ -217,12 +217,12 @@ Route::group(['middleware' => 'auth'], function () {
 });
 
 // Social auth routes
-Route::get('/login/service/{socialDriver}', 'Auth\SocialController@getSocialLogin');
-Route::get('/login/service/{socialDriver}/callback', 'Auth\SocialController@socialCallback');
+Route::get('/login/service/{socialDriver}', 'Auth\SocialController@login');
+Route::get('/login/service/{socialDriver}/callback', 'Auth\SocialController@callback');
 Route::group(['middleware' => 'auth'], function () {
-    Route::get('/login/service/{socialDriver}/detach', 'Auth\SocialController@detachSocialAccount');
+    Route::get('/login/service/{socialDriver}/detach', 'Auth\SocialController@detach');
 });
-Route::get('/register/service/{socialDriver}', 'Auth\SocialController@socialRegister');
+Route::get('/register/service/{socialDriver}', 'Auth\SocialController@register');
 
 // Login/Logout routes
 Route::get('/login', 'Auth\LoginController@getLogin');