-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
76c826c
commit 0b18ae5
Showing
16 changed files
with
403 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Controllers\Connections; | ||
|
||
use App\Models\UserConnection; | ||
use Exception; | ||
use Illuminate\Http\RedirectResponse; | ||
use Laravel\Socialite\Two\InvalidStateException; | ||
use Symfony\Component\HttpFoundation\RedirectResponse as SymfonyRedirectResponse; | ||
|
||
class BitbucketController extends ConnectionsController | ||
{ | ||
/** @var string The provider name for Bitbucket */ | ||
private const PROVIDER_NAME = UserConnection::PROVIDER_BITBUCKET; | ||
|
||
/** | ||
* Redirect the user to Bitbucket's authentication page. | ||
*/ | ||
public function redirect(): RedirectResponse|SymfonyRedirectResponse | ||
{ | ||
return $this->redirectToProvider(self::PROVIDER_NAME); | ||
} | ||
|
||
/** | ||
* Handle the callback from Bitbucket. | ||
*/ | ||
public function callback(): RedirectResponse | ||
{ | ||
try { | ||
return $this->handleProviderCallback(self::PROVIDER_NAME); | ||
} catch (InvalidStateException) { | ||
return $this->handleInvalidState(); | ||
} catch (Exception $e) { | ||
return $this->handleGenericError($e); | ||
} | ||
} | ||
|
||
/** | ||
* Handle invalid state exception, which could occur if the user cancels the process. | ||
*/ | ||
protected function handleInvalidState(): RedirectResponse | ||
{ | ||
return redirect()->route('login') | ||
->with('loginError', 'Bitbucket connection was cancelled or invalid. Please try again if you want to connect your account.'); | ||
} | ||
|
||
/** | ||
* Handle generic errors during the Bitbucket connection process. | ||
*/ | ||
protected function handleGenericError(Exception $exception): RedirectResponse | ||
{ | ||
logger()->error('Bitbucket connection error', ['error' => $exception->getMessage()]); | ||
|
||
return redirect()->route('login') | ||
->with('loginError', 'An error occurred while connecting to Bitbucket. Please try again later.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<svg fill="#1A74ED" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" {{ $attributes->merge() }}><title>Bitbucket</title> | ||
<path | ||
d="M.778 1.213a.768.768 0 00-.768.892l3.263 19.81c.084.5.515.868 1.022.873H19.95a.772.772 0 00.77-.646l3.27-20.03a.768.768 0 00-.768-.891zM14.52 15.53H9.522L8.17 8.466h7.561z"/> | ||
</svg> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.