Skip to content

Commit

Permalink
swap to beta app
Browse files Browse the repository at this point in the history
  • Loading branch information
fokosun committed Oct 10, 2023
1 parent e1018f5 commit 9427eba
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 28 deletions.
35 changes: 15 additions & 20 deletions app/Http/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand All @@ -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')]
));
}
}

Expand Down
9 changes: 3 additions & 6 deletions app/Utils/UriHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
10 changes: 8 additions & 2 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/?'
]
]
];

0 comments on commit 9427eba

Please sign in to comment.