-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: dispatch event when an OAuth login is successful (#4)
* feat: dispatch event when an OAuth login is successful * Apply fixes from StyleCI --------- Co-authored-by: StyleCI Bot <[email protected]>
- Loading branch information
1 parent
f02c71d
commit 2dec4e8
Showing
3 changed files
with
87 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,8 @@ | |
"psr-4": { | ||
"FoF\\Extend\\": "src/" | ||
} | ||
}, | ||
"require-dev": { | ||
"league/oauth2-client": "^2.7" | ||
} | ||
} |
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,65 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of fof/extend. | ||
* | ||
* Copyright (c) FriendsOfFlarum. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FoF\Extend\Events; | ||
|
||
use Flarum\User\User; | ||
use League\OAuth2\Client\Provider\ResourceOwnerInterface; | ||
use League\OAuth2\Client\Token\AccessToken; | ||
|
||
class OAuthLoginSuccessful | ||
{ | ||
/** | ||
* The access token provided by the service. | ||
* | ||
* @var AccessToken | ||
*/ | ||
public $token; | ||
|
||
/** | ||
* THe complete ResourceOwner object. | ||
* | ||
* @var ResourceOwnerInterface | ||
*/ | ||
public $userResource; | ||
|
||
/** | ||
* The OAuth provider name. This is used in the `login_providers` table as the `provider` column. | ||
* | ||
* @var string | ||
*/ | ||
public $providerName; | ||
|
||
/** | ||
* The providers unique identifier as given by the provider. This is used in the `login_providers` table as the `identifier` column. | ||
* | ||
* @var string | ||
*/ | ||
public $identifier; | ||
|
||
/** | ||
* For a "normal" login, this value will always be `Guest`, as when this event is dispatched we have not yet completed the complete login flow. | ||
* | ||
* If a logged in user is attemping to link their existing Flarum account with a OAuth provider, this will contain the current user object. | ||
* | ||
* @var ?User | ||
*/ | ||
public $actor; | ||
|
||
public function __construct(AccessToken $token, ResourceOwnerInterface $userResource, string $providerName, string $identifier, ?User $actor) | ||
{ | ||
$this->token = $token; | ||
$this->userResource = $userResource; | ||
$this->providerName = $providerName; | ||
$this->identifier = $identifier; | ||
$this->actor = $actor; | ||
} | ||
} |