Browse Source

Fix OAuth route issue

兔姬桑 4 years ago
parent
commit
a2ae0b74d0
2 changed files with 11 additions and 7 deletions
  1. 10 6
      app/Http/Controllers/OAuth/BaseController.php
  2. 1 1
      readme.md

+ 10 - 6
app/Http/Controllers/OAuth/BaseController.php

@@ -17,15 +17,16 @@ class BaseController extends Controller
     public function route(Request $request, string $type)
     {
         $action = $request->input('action');
+        $key = "services.{$type}.redirect";
         if ($action === 'binding') {
-            return Socialite::driver($type)->with(['redirect_uri' => route('oauth.bind', ['type' => $type])])->redirect();
+            config([$key => route('oauth.bind', ['type' => $type])]);
+        } elseif ($action === 'register') {
+            config([$key => route('oauth.register', ['type' => $type])]);
+        } else {
+            config([$key => route('oauth.login', ['type' => $type])]);
         }
 
-        if ($action === 'register') {
-            return Socialite::driver($type)->with(['redirect_uri' => route('oauth.register', ['type' => $type])])->redirect();
-        }
-
-        return Socialite::driver($type)->with(['redirect_uri' => route('oauth.login', ['type' => $type])])->redirect();
+        return Socialite::driver($type)->redirect();
     }
 
     public function simple(string $type)
@@ -91,6 +92,7 @@ class BaseController extends Controller
 
     public function binding($type)
     {
+        config(["services.{$type}.redirect" => route('oauth.bind', ['type' => $type])]);
         $info = Socialite::driver($type)->stateless()->user();
 
         if ($info) {
@@ -107,6 +109,7 @@ class BaseController extends Controller
 
     public function logining($type)
     {
+        config(["services.{$type}.redirect" => route('oauth.login', ['type' => $type])]);
         $info = Socialite::driver($type)->stateless()->user();
         if ($info) {
             return $this->login($type, $info);
@@ -117,6 +120,7 @@ class BaseController extends Controller
 
     public function register($type)
     {
+        config(["services.{$type}.redirect" => route('oauth.register', ['type' => $type])]);
         $info = Socialite::driver($type)->stateless()->user();
 
         // 排除重复用户注册

+ 1 - 1
readme.md

@@ -14,7 +14,7 @@ Support but not limited to: Shadowsocks,ShadowsocksR,ShadowsocksRR,V2Ray,Trojan,
 
 ## Funding
 Buy me a Coffee?
-- PayPal [paypal.me/brettonye](paypal.me/brettonye)
+- PayPal [paypal.me/brettonye](https://www.paypal.com/paypalme/brettonye)
 - USDT-TRC20 TFMxq91oPCnoxDXBiEgRzab5N6GFnAbTT5
 
 ## Requirements