diff --git a/app/assets/less/base/typography.less b/app/assets/less/base/typography.less index e8d6b05..559ba48 100644 --- a/app/assets/less/base/typography.less +++ b/app/assets/less/base/typography.less @@ -11,3 +11,4 @@ .text-github { color: @github-color; } .text-gitlab { color: @gitlab-color; } .text-google { color: @google-color; } +.text-linkedin { color: @linkedin-color; } diff --git a/app/assets/less/components/button.less b/app/assets/less/components/button.less index 3c57b37..4d2e596 100644 --- a/app/assets/less/components/button.less +++ b/app/assets/less/components/button.less @@ -48,6 +48,7 @@ .button-github { .button-variant(@button-github-color, @button-github-bg); } .button-gitlab { .button-variant(@button-gitlab-color, @button-gitlab-bg); } .button-google { .button-variant(@button-google-color, @button-google-bg); } +.button-linkedin { .button-variant(@button-linkedin-color, @button-linkedin-bg); } // Outline // ---------------------------------- diff --git a/app/assets/less/variables.less b/app/assets/less/variables.less index fb7f240..0576ada 100644 --- a/app/assets/less/variables.less +++ b/app/assets/less/variables.less @@ -32,6 +32,7 @@ @google-color: #db4437; @github-color: #4183c4; @gitlab-color: #548; +@linkedin-color: #0077B5; // ---------------------------------- // Font @@ -116,6 +117,9 @@ @button-gitlab-color: white; @button-gitlab-bg: @gitlab-color; +@button-linkedin-color: white; +@button-linkedin-bg: @linkedin-color; + // ---------------------------------- // Shadows // ---------------------------------- diff --git a/app/library/OAuth/Adapter/League.php b/app/library/OAuth/Adapter/League.php index 3d04fdf..cf27257 100644 --- a/app/library/OAuth/Adapter/League.php +++ b/app/library/OAuth/Adapter/League.php @@ -13,9 +13,10 @@ class League implements AdapterInterface * @var array */ protected $_providerClasses = array( - 'github' => '\League\OAuth2\Client\Provider\Github', - 'gitlab' => '\Omines\OAuth2\Client\Provider\Gitlab', - 'google' => '\League\OAuth2\Client\Provider\Google', + 'github' => '\League\OAuth2\Client\Provider\Github', + 'gitlab' => '\Omines\OAuth2\Client\Provider\Gitlab', + 'google' => '\League\OAuth2\Client\Provider\Google', + 'linkedin' => '\League\OAuth2\Client\Provider\LinkedIn', ); /** diff --git a/app/library/OAuth/UserData/LinkedIn.php b/app/library/OAuth/UserData/LinkedIn.php new file mode 100644 index 0000000..60b6e4f --- /dev/null +++ b/app/library/OAuth/UserData/LinkedIn.php @@ -0,0 +1,63 @@ +data = $data; + } + + /** + * {@inheritDoc} + */ + public function getProvider() + { + return 'LinkedIn'; + } + + /** + * {@inheritDoc} + */ + public function getId() + { + return $this->data['id']; + } + + /** + * {@inheritDoc} + */ + public function getUsername() + { + return null; + } + + /** + * {@inheritDoc} + */ + public function getName() + { + $name = ''; + if (isset($this->data['firstName'])) { + $name = $this->data['firstName']; + } + if (isset($this->data['lastName'])) { + $name .= ' ' . $this->data['lastName']; + } + return $name; + } + + /** + * {@inheritDoc} + */ + public function getEmail() + { + return $this->data['emailAddress']; + } +} diff --git a/app/migrations/20180808200726_user_oauth_linkedin.php b/app/migrations/20180808200726_user_oauth_linkedin.php new file mode 100644 index 0000000..fca7562 --- /dev/null +++ b/app/migrations/20180808200726_user_oauth_linkedin.php @@ -0,0 +1,17 @@ +table('user') + ->addColumn('linkedin_id', 'string', [ + 'limit' => 16, + 'null' => true, + 'after' => 'google_id' + ])->save(); + } +} diff --git a/app/models/Data/User.php b/app/models/Data/User.php index f679c3b..fdeb5bf 100644 --- a/app/models/Data/User.php +++ b/app/models/Data/User.php @@ -32,6 +32,8 @@ class User extends Model protected $google_id; + protected $linkedin_id; + public function initialize() { $this->useDynamicUpdate(true); @@ -227,12 +229,31 @@ class User extends Model return $this; } + /** + * @return string|null + */ + public function getLinkedinId() + { + return $this->linkedin_id; + } + + /** + * @param string $id + * @return User + */ + public function setLinkedinId($id) + { + $this->linkedin_id = (string) $id; + return $this; + } + public function getSocialLinks() { $providers = [ - 'github' => $this->getGithubId(), - 'gitlab' => $this->getGitlabId(), - 'google' => $this->getGoogleId() + 'github' => $this->getGithubId(), + 'gitlab' => $this->getGitlabId(), + 'google' => $this->getGoogleId(), + 'linkedin' => $this->getLinkedinId() ]; return array_filter($providers); diff --git a/app/views/auth/index.volt b/app/views/auth/index.volt index 299400b..512a11f 100644 --- a/app/views/auth/index.volt +++ b/app/views/auth/index.volt @@ -41,6 +41,10 @@ {{ icon('brand/gitlab') }} Gitlab + + + {{ icon('brand/linkedin') }} LinkedIn + diff --git a/app/views/user/settings.volt b/app/views/user/settings.volt index 3f3af81..ef5a814 100644 --- a/app/views/user/settings.volt +++ b/app/views/user/settings.volt @@ -1,8 +1,9 @@ {% set social_links = [ - 'github' : [ 'connected': user.getGithubId() > 0 ], - 'gitlab' : [ 'connected': user.getGitlabId() > 0, 'class': 'text-gitlab' ], - 'google' : [ 'connected': user.getGoogleId() > 0, 'class': 'text-google' ] + 'github' : [ 'connected': user.getGithubId() > 0 ], + 'gitlab' : [ 'connected': user.getGitlabId() > 0, 'class': 'text-gitlab' ], + 'google' : [ 'connected': user.getGoogleId() > 0, 'class': 'text-google' ], + 'linkedin' : [ 'connected': user.getLinkedinId() | length, 'class': 'text-linkedin' ] ] %} diff --git a/composer.json b/composer.json index 8253898..00189ee 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,7 @@ "league/oauth2-client": "^2.3", "league/oauth2-github": "^2.0", "league/oauth2-google": "^2.2", + "league/oauth2-linkedin": "^4.1", "omines/oauth2-gitlab": "^3.1", "localheinz/json-printer": "^2.0", "sendgrid/sendgrid": "^7.0" diff --git a/composer.lock b/composer.lock index 2db35ed..94ef099 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "01d955324dab45a8647cc235d2a93d68", - "content-hash": "b2a64be9535ccaf045a7155343a64ec9", + "hash": "4c349858d6d2e69304bd4df64d883073", + "content-hash": "e1a15725333e7544dbae37ff27e14ffb", "packages": [ { "name": "guzzlehttp/guzzle", @@ -361,6 +361,61 @@ ], "time": "2018-03-19 17:28:55" }, + { + "name": "league/oauth2-linkedin", + "version": "4.1.1", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/oauth2-linkedin.git", + "reference": "0dfb338db84cb87c3d24b0205ec7f3e3a9457b81" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/oauth2-linkedin/zipball/0dfb338db84cb87c3d24b0205ec7f3e3a9457b81", + "reference": "0dfb338db84cb87c3d24b0205ec7f3e3a9457b81", + "shasum": "" + }, + "require": { + "league/oauth2-client": "^2.0" + }, + "require-dev": { + "mockery/mockery": "~0.9", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "League\\OAuth2\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Steven Maguire", + "email": "stevenmaguire@gmail.com", + "homepage": "https://github.com/stevenmaguire" + } + ], + "description": "LinkedIn OAuth 2.0 Client Provider for The PHP League OAuth2-Client", + "keywords": [ + "authorisation", + "authorization", + "client", + "linkedin", + "oauth", + "oauth2" + ], + "time": "2018-07-23 15:43:54" + }, { "name": "localheinz/json-printer", "version": "2.0.0", @@ -1220,7 +1275,7 @@ "platform": { "php": ">=7.0.0", "ext-phalcon": ">=3.4.0", - "ext-apc": "*" + "ext-redis": "*" }, "platform-dev": [] }