Skip to content

Commit

Permalink
Merge branch 'craft-4' of https://github.com/verbb/social-login into …
Browse files Browse the repository at this point in the history
…craft-5

# Conflicts:
#	CHANGELOG.md
#	composer.json
  • Loading branch information
engram-design committed Jul 15, 2024
2 parents 51470a2 + 13273e5 commit d0ecb16
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 1 deletion.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@
### Fixed
- Fix race conditions with plugin initialization. (thanks @nfourtythree).

## 1.0.16 - 2024-07-15

### Added
- Add `sendActivationEmail` plugin setting.
- Add the ability to set `data` for a login request, where users might want to store extra information.
- Add Amazon Cognito provider.

### Changed
- Now requires Craft 4.3.5+.
- Revert callback URI change for `cpTrigger = null` (for detached CPs).

### Fixed
- Fix race conditions with plugin initialization. (thanks @nfourtythree).
- Fix activation email logic.

## 1.0.15 - 2024-05-29

### Added
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"require": {
"php": "^8.2",
"craftcms/cms": "^5.0.0",
"verbb/auth": "^2.0.3",
"verbb/auth": "^2.0.6",
"verbb/base": "^3.0.0"
},
"autoload": {
Expand Down
43 changes: 43 additions & 0 deletions src/providers/AmazonCognito.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
namespace verbb\sociallogin\providers;

use verbb\sociallogin\base\OAuthProvider;

use Craft;

use verbb\auth\providers\AmazonCognito as AmazonCognitoProvider;

class AmazonCognito extends OAuthProvider
{
// Static Methods
// =========================================================================

public static function displayName(): string
{
return Craft::t('social-login', 'Amazon Cognito');
}

public static function getOAuthProviderClass(): string
{
return AmazonCognitoProvider::class;
}


// Properties
// =========================================================================

public static string $handle = 'amazonCognito';


// Public Methods
// =========================================================================

public function getUserProfileFields(): array
{
return [
'name',
'postalCode',
];
}

}
1 change: 1 addition & 0 deletions src/services/Providers.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function getAllProviderTypes(): array
{
$providerTypes = [
providerTypes\Amazon::class,
providerTypes\AmazonCognito::class,
providerTypes\Apple::class,
providerTypes\Auth0::class,
providerTypes\Azure::class,
Expand Down
9 changes: 9 additions & 0 deletions src/services/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public function loginOrRegisterUser(Provider $provider, Token $token): bool
// With the user authenticated, login or register
$user = Craft::$app->getUser()->getIdentity();

// Fetch plugin settings
$settings = SocialLogin::$plugin->getSettings();

if (!$user) {
$user = $this->_getOrCreateUser($provider, $userProfile);

Expand All @@ -50,6 +53,12 @@ public function loginOrRegisterUser(Provider $provider, Token $token): bool

return false;
}
} else if ($settings->populateProfile && $settings->syncProfile) {
// Ensure we sync the User's profile on each login/register request. This ensures profile data is synced
// when using an edit profile URL from the SSO provider, for example.

$user = $this->_syncUserProfile($provider, $user, $userProfile);
Craft::$app->getElements()->saveElement($user);
}

// Are we resuming an already-logged in session (through the modal login)? Ensure that things match,
Expand Down
1 change: 1 addition & 0 deletions src/templates/providers/amazon-cognito.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% include 'social-login/providers/_oauth' %}

0 comments on commit d0ecb16

Please sign in to comment.