From f1a1804851cf3b73a17f20a1b0b90114ad075a5e Mon Sep 17 00:00:00 2001 From: fokosun Date: Tue, 10 Oct 2023 04:30:56 -0400 Subject: [PATCH] swap to beta app --- app/Http/Controllers/AuthController.php | 35 +++++++++++-------------- app/Utils/UriHelper.php | 9 +++---- config/services.php | 10 +++++-- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index e154528..3e0d683 100755 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -13,7 +13,6 @@ use App\Services\LocationService; use App\Services\UserService; use App\Utils\UriHelper; -use GuzzleHttp\Client; use GuzzleHttp\Exception\GuzzleException; use Illuminate\Http\Request; use Illuminate\Http\Response; @@ -194,12 +193,10 @@ public function tikTokHandleCallback(Request $request, TikTokHttpClient $httpCli ]; if (!$token = Auth::attempt($credentials)) { - return UriHelper::redirectToUrl( - UriHelper::buildHttpQuery( - 'errors', - ['m' => Lang::get('errors.generic')] - ) - ); + return redirect(UriHelper::buildHttpQuery( + 'errors', + ['m' => Lang::get('errors.generic')] + )); } TikTokUserIsAuthenticated::dispatch(new TikTokUserDto( @@ -217,26 +214,24 @@ public function tikTokHandleCallback(Request $request, TikTokHttpClient $httpCli Arr::get($userInfo, 'data.user.video_count') )); - $to = UriHelper::buildHttpQuery('tiktok', ['token' => $token, '_d' => $user->getSlug()]); - - return UriHelper::redirectToUrl($to); - } else { - return UriHelper::redirectToUrl( + return redirect( UriHelper::buildHttpQuery( - 'errors', - ['m' => Lang::get('errors.login.tiktok.private_account')] + 'tiktok', ['token' => $token, '_d' => $user->getSlug()] ) ); + } else { + return redirect(UriHelper::buildHttpQuery( + 'errors', + ['m' => Lang::get('errors.login.tiktok.private_account')] + )); } } catch (\Exception $e) { Log::debug('Tiktok Login error', ['errorCode' => $errCode, 'errorMsg' => $e->getMessage()]); - return UriHelper::redirectToUrl( - UriHelper::buildHttpQuery( - 'errors', - ['m' => Lang::get('errors.login.tiktok.generic')] - ) - ); + return redirect(UriHelper::buildHttpQuery( + 'errors', + ['m' => Lang::get('errors.login.tiktok.generic')] + )); } } diff --git a/app/Utils/UriHelper.php b/app/Utils/UriHelper.php index 116205a..b4bec42 100644 --- a/app/Utils/UriHelper.php +++ b/app/Utils/UriHelper.php @@ -6,13 +6,10 @@ class UriHelper { - public static function buildHttpQuery(string $redirectTo, array $parameters): string + public static function buildHttpQuery(string $redirectToPage, array $parameters): string { - return config('services.redirects.' . $redirectTo) . http_build_query($parameters); - } + $redirectToPage = $redirectToPage . 'beta-version-1-staging'; - public static function redirectToUrl($to) - { - return redirect($to); + return config('services.redirects.' . $redirectToPage) . http_build_query($parameters); } } diff --git a/config/services.php b/config/services.php index 94b3e0f..b96bdef 100755 --- a/config/services.php +++ b/config/services.php @@ -52,7 +52,13 @@ 'validity' => 15 //mins ], 'redirects' => [ - 'tiktok' => env('VUE2_APP_URL') . 'tiktok/?', - 'errors' => env('VUE2_APP_URL') . 'errors/?', + 'tiktok' => [ + 'web-client-vue2' => env('VUE2_APP_URL') . 'tiktok/?', + 'beta-version-1-staging' => env('NUXT_APP_URL') . 'tiktok/?' + ], + 'errors' => [ + 'web-client-vue2' => env('VUE2_APP_URL') . 'errors/?', + 'beta-version-1-staging' => env('NUXT_APP_URL') . 'errors/?' + ] ] ];