add facebook login module, hwi/HWIOAuthBundle
This commit is contained in:
@@ -19,6 +19,7 @@ class AppKernel extends Kernel
|
|||||||
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
|
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
|
||||||
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
|
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
|
||||||
new FOS\UserBundle\FOSUserBundle(),
|
new FOS\UserBundle\FOSUserBundle(),
|
||||||
|
new HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
|
||||||
new Gos\Bundle\WebSocketBundle\GosWebSocketBundle(),
|
new Gos\Bundle\WebSocketBundle\GosWebSocketBundle(),
|
||||||
new Gos\Bundle\PubSubRouterBundle\GosPubSubRouterBundle(),
|
new Gos\Bundle\PubSubRouterBundle\GosPubSubRouterBundle(),
|
||||||
new Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
|
new Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
|
||||||
|
|||||||
@@ -11,6 +11,22 @@ security:
|
|||||||
id: fos_user.user_provider.username_email
|
id: fos_user.user_provider.username_email
|
||||||
|
|
||||||
firewalls:
|
firewalls:
|
||||||
|
secured_area:
|
||||||
|
anonymous: ~
|
||||||
|
oauth:
|
||||||
|
resource_owners:
|
||||||
|
facebook: /login/check-facebook
|
||||||
|
google: /login/check-google
|
||||||
|
my_github: /login/check-github
|
||||||
|
login_path: /login
|
||||||
|
failure_path: /login
|
||||||
|
use_forward: false
|
||||||
|
|
||||||
|
oauth_user_provider:
|
||||||
|
service: my.custom.user_provider
|
||||||
|
logout:
|
||||||
|
path: /logout
|
||||||
|
target: /
|
||||||
main:
|
main:
|
||||||
pattern: ^/
|
pattern: ^/
|
||||||
form_login:
|
form_login:
|
||||||
@@ -22,7 +38,8 @@ security:
|
|||||||
anonymous: true
|
anonymous: true
|
||||||
|
|
||||||
access_control:
|
access_control:
|
||||||
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
|
- { path: ^/play, role: ROLE_USER }
|
||||||
- { path: ^/admin, role: ROLE_SUPER_ADMIN }
|
- { path: ^/admin, role: ROLE_SUPER_ADMIN }
|
||||||
|
|||||||
@@ -33,7 +33,8 @@
|
|||||||
"doctrine/doctrine-migrations-bundle": "^1.0",
|
"doctrine/doctrine-migrations-bundle": "^1.0",
|
||||||
"symfony/assetic-bundle": "^2.8",
|
"symfony/assetic-bundle": "^2.8",
|
||||||
"predis/predis": "^1.0",
|
"predis/predis": "^1.0",
|
||||||
"snc/redis-bundle": "^2.0"
|
"snc/redis-bundle": "^2.0",
|
||||||
|
"hwi/oauth-bundle": "^0.5.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"sensio/generator-bundle": "^3.0",
|
"sensio/generator-bundle": "^3.0",
|
||||||
|
|||||||
201
composer.lock
generated
201
composer.lock
generated
@@ -4,8 +4,8 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "7c1e046373c318178e58c9617d9c6931",
|
"hash": "9ab894ab9dec6a53088c8bea70e8ee9a",
|
||||||
"content-hash": "b09b605e8d336a4e0bf774ce6f486957",
|
"content-hash": "06afd75cc129d2765a6803d384805417",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "doctrine/annotations",
|
"name": "doctrine/annotations",
|
||||||
@@ -1560,6 +1560,155 @@
|
|||||||
"abandoned": "guzzle/guzzle",
|
"abandoned": "guzzle/guzzle",
|
||||||
"time": "2014-05-01 21:36:02"
|
"time": "2014-05-01 21:36:02"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "hwi/oauth-bundle",
|
||||||
|
"version": "0.5.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/hwi/HWIOAuthBundle.git",
|
||||||
|
"reference": "429ae3fe1641a54ea0934bb06dac355affc41f8d"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/hwi/HWIOAuthBundle/zipball/429ae3fe1641a54ea0934bb06dac355affc41f8d",
|
||||||
|
"reference": "429ae3fe1641a54ea0934bb06dac355affc41f8d",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"kriswallsmith/buzz": "~0.13",
|
||||||
|
"php": ">=5.3.3",
|
||||||
|
"symfony/form": "~2.3|~3.0",
|
||||||
|
"symfony/framework-bundle": "~2.3|~3.0",
|
||||||
|
"symfony/options-resolver": "~2.3|~3.0",
|
||||||
|
"symfony/security-bundle": "~2.3|~3.0",
|
||||||
|
"symfony/yaml": "~2.3|~3.0"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"twig/twig": "<1.12"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"doctrine/orm": "~2.3",
|
||||||
|
"fabpot/php-cs-fixer": "~1.11",
|
||||||
|
"friendsofsymfony/user-bundle": "~1.3|~2.0",
|
||||||
|
"phpunit/phpunit": "~4.8|~5.0",
|
||||||
|
"symfony/phpunit-bridge": "~2.7|~3.0",
|
||||||
|
"symfony/property-access": "~2.3|~3.0",
|
||||||
|
"symfony/stopwatch": "~2.5|~3.0",
|
||||||
|
"symfony/twig-bundle": "~2.3|~3.0",
|
||||||
|
"symfony/validator": "~2.3|~3.0"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"doctrine/doctrine-bundle": "to use Doctrine user provider",
|
||||||
|
"friendsofsymfony/user-bundle": "to connect FOSUB with this bundle",
|
||||||
|
"symfony/property-access": "to use FOSUB integration with this bundle",
|
||||||
|
"symfony/twig-bundle": "to use the Twig hwi_oauth_* functions"
|
||||||
|
},
|
||||||
|
"type": "symfony-bundle",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "0.5-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"HWI\\Bundle\\OAuthBundle\\": ""
|
||||||
|
},
|
||||||
|
"exclude-from-classmap": [
|
||||||
|
"/Tests/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Contributors",
|
||||||
|
"homepage": "https://github.com/hwi/HWIOAuthBundle/contributors"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Joseph Bielawski",
|
||||||
|
"email": "stloyd@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Alexander",
|
||||||
|
"email": "iam.asm89@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Geoffrey Bachelet",
|
||||||
|
"email": "geoffrey.bachelet@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Support for authenticating users using both OAuth1.0a and OAuth2 in Symfony2.",
|
||||||
|
"homepage": "http://github.com/hwi/HWIOAuthBundle",
|
||||||
|
"keywords": [
|
||||||
|
"37signals",
|
||||||
|
"Authentication",
|
||||||
|
"Deezer",
|
||||||
|
"EVE Online",
|
||||||
|
"amazon",
|
||||||
|
"asana",
|
||||||
|
"auth0",
|
||||||
|
"azure",
|
||||||
|
"bitbucket",
|
||||||
|
"bitly",
|
||||||
|
"box",
|
||||||
|
"bufferapp",
|
||||||
|
"clever",
|
||||||
|
"dailymotion",
|
||||||
|
"deviantart",
|
||||||
|
"discogs",
|
||||||
|
"disqus",
|
||||||
|
"dropbox",
|
||||||
|
"eventbrite",
|
||||||
|
"facebook",
|
||||||
|
"firewall",
|
||||||
|
"fiware",
|
||||||
|
"flickr",
|
||||||
|
"foursquare",
|
||||||
|
"github",
|
||||||
|
"google",
|
||||||
|
"hubic",
|
||||||
|
"instagram",
|
||||||
|
"jawbone",
|
||||||
|
"jira",
|
||||||
|
"linkedin",
|
||||||
|
"mail.ru",
|
||||||
|
"oauth",
|
||||||
|
"oauth1",
|
||||||
|
"oauth2",
|
||||||
|
"odnoklassniki",
|
||||||
|
"paypal",
|
||||||
|
"qq",
|
||||||
|
"reddit",
|
||||||
|
"runkeeper",
|
||||||
|
"salesforce",
|
||||||
|
"security",
|
||||||
|
"sensio connect",
|
||||||
|
"sina weibo",
|
||||||
|
"slack",
|
||||||
|
"sound cloud",
|
||||||
|
"spotify",
|
||||||
|
"stack exchange",
|
||||||
|
"stereomood",
|
||||||
|
"strava",
|
||||||
|
"toshl",
|
||||||
|
"trakt",
|
||||||
|
"trello",
|
||||||
|
"twitch",
|
||||||
|
"twitter",
|
||||||
|
"vkontakte",
|
||||||
|
"wechat",
|
||||||
|
"windows live",
|
||||||
|
"wordpress",
|
||||||
|
"wunderlist",
|
||||||
|
"xing",
|
||||||
|
"yahoo",
|
||||||
|
"yandex",
|
||||||
|
"youtube"
|
||||||
|
],
|
||||||
|
"time": "2016-10-03 14:27:17"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "incenteev/composer-parameter-handler",
|
"name": "incenteev/composer-parameter-handler",
|
||||||
"version": "v2.1.2",
|
"version": "v2.1.2",
|
||||||
@@ -1738,6 +1887,54 @@
|
|||||||
],
|
],
|
||||||
"time": "2015-11-12 13:51:40"
|
"time": "2015-11-12 13:51:40"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "kriswallsmith/buzz",
|
||||||
|
"version": "v0.15",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/kriswallsmith/Buzz.git",
|
||||||
|
"reference": "d4041666c3ffb379af02a92dabe81c904b35fab8"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/kriswallsmith/Buzz/zipball/d4041666c3ffb379af02a92dabe81c904b35fab8",
|
||||||
|
"reference": "d4041666c3ffb379af02a92dabe81c904b35fab8",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "3.7.*"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-curl": "*"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-0": {
|
||||||
|
"Buzz": "lib/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Kris Wallsmith",
|
||||||
|
"email": "kris.wallsmith@gmail.com",
|
||||||
|
"homepage": "http://kriswallsmith.net/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Lightweight HTTP client",
|
||||||
|
"homepage": "https://github.com/kriswallsmith/Buzz",
|
||||||
|
"keywords": [
|
||||||
|
"curl",
|
||||||
|
"http client"
|
||||||
|
],
|
||||||
|
"time": "2015-06-25 17:26:56"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "monolog/monolog",
|
"name": "monolog/monolog",
|
||||||
"version": "1.21.0",
|
"version": "1.21.0",
|
||||||
|
|||||||
@@ -21,8 +21,58 @@ class User extends BaseUser
|
|||||||
*/
|
*/
|
||||||
protected $id;
|
protected $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(name="facebook_id", type="string", length=255, nullable=true)
|
||||||
|
*/
|
||||||
|
private $facebookId;
|
||||||
|
|
||||||
|
private $facebookAccessToken;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set facebookId
|
||||||
|
*
|
||||||
|
* @param string $facebookId
|
||||||
|
*
|
||||||
|
* @return User
|
||||||
|
*/
|
||||||
|
public function setFacebookId($facebookId)
|
||||||
|
{
|
||||||
|
$this->facebookId = $facebookId;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get facebookId
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFacebookId()
|
||||||
|
{
|
||||||
|
return $this->facebookId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $facebookAccessToken
|
||||||
|
* @return User
|
||||||
|
*/
|
||||||
|
public function setFacebookAccessToken($facebookAccessToken)
|
||||||
|
{
|
||||||
|
$this->facebookAccessToken = $facebookAccessToken;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFacebookAccessToken()
|
||||||
|
{
|
||||||
|
return $this->facebookAccessToken;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,39 @@ class User extends BaseUser
|
|||||||
*/
|
*/
|
||||||
protected $id;
|
protected $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(name="facebook_id", type="string", length=255, nullable=true)
|
||||||
|
*/
|
||||||
|
private $facebookId;
|
||||||
|
|
||||||
|
private $facebookAccessToken;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set facebookId
|
||||||
|
*
|
||||||
|
* @param string $facebookId
|
||||||
|
*
|
||||||
|
* @return User
|
||||||
|
*/
|
||||||
|
public function setFacebookId($facebookId)
|
||||||
|
{
|
||||||
|
$this->facebookId = $facebookId;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get facebookId
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFacebookId()
|
||||||
|
{
|
||||||
|
return $this->facebookId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,3 +7,16 @@ twig:
|
|||||||
project_name: 'MineSeeker'
|
project_name: 'MineSeeker'
|
||||||
project_shortname: 'Mine'
|
project_shortname: 'Mine'
|
||||||
project_monogram: 'MS'
|
project_monogram: 'MS'
|
||||||
|
|
||||||
|
hwi_oauth:
|
||||||
|
firewall_names: [secured_area]
|
||||||
|
resource_owners:
|
||||||
|
facebook:
|
||||||
|
type: facebook
|
||||||
|
client_id: 320599508311862
|
||||||
|
client_secret: 18d4f48cdd274bccee2678e5eff3f557
|
||||||
|
scope: ""
|
||||||
|
options:
|
||||||
|
display: popup
|
||||||
|
auth_type: rerequest
|
||||||
|
csrf: true
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
hwi_oauth_redirect:
|
||||||
|
resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
|
||||||
|
prefix: /connect
|
||||||
|
|
||||||
|
hwi_oauth_login:
|
||||||
|
resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
|
||||||
|
prefix: /login
|
||||||
|
|
||||||
|
facebook_login:
|
||||||
|
path: /login/check-facebook
|
||||||
|
|
||||||
|
google_login:
|
||||||
|
path: /login/check-google
|
||||||
|
|
||||||
|
github_login:
|
||||||
|
path: /login/check-github
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
services:
|
services:
|
||||||
# jotunheimr_user.example:
|
my.custom.user_provider:
|
||||||
# class: Jotunheimr\UserBundle\Example
|
class: Jotunheimr\UserBundle\Security\Core\User\MyFOSUBUserProvider
|
||||||
# arguments: ["@service_id", "plain_value", %parameter%]
|
arguments: ['@fos_user.user_manager', { facebook: facebookId }]
|
||||||
|
|||||||
@@ -3,6 +3,46 @@
|
|||||||
{% trans_default_domain 'FOSUserBundle' %}
|
{% trans_default_domain 'FOSUserBundle' %}
|
||||||
|
|
||||||
{% block fos_user_content %}
|
{% block fos_user_content %}
|
||||||
|
<script>
|
||||||
|
window.fbAsyncInit = function() {
|
||||||
|
FB.init({
|
||||||
|
appId : '320599508311862',
|
||||||
|
xfbml : true,
|
||||||
|
version : 'v2.8'
|
||||||
|
});
|
||||||
|
FB.AppEvents.logPageView();
|
||||||
|
};
|
||||||
|
|
||||||
|
(function(d, s, id){
|
||||||
|
var js, fjs = d.getElementsByTagName(s)[0];
|
||||||
|
if (d.getElementById(id)) {return;}
|
||||||
|
js = d.createElement(s); js.id = id;
|
||||||
|
js.src = "//connect.facebook.net/en_US/sdk.js";
|
||||||
|
fjs.parentNode.insertBefore(js, fjs);
|
||||||
|
}(document, 'script', 'facebook-jssdk'));
|
||||||
|
|
||||||
|
function fb_login() {
|
||||||
|
FB.getLoginStatus(function(response) {
|
||||||
|
if (response.status === 'connected') {
|
||||||
|
// connected
|
||||||
|
alert('Already connected, redirect to login page to create token.');
|
||||||
|
document.location = "{{ url("hwi_oauth_service_redirect", {service: "facebook"}) }}";
|
||||||
|
} else {
|
||||||
|
// not_authorized
|
||||||
|
FB.login(function(response) {
|
||||||
|
if (response.authResponse) {
|
||||||
|
document.location = "{{ url("hwi_oauth_service_redirect", {service: "facebook"}) }}";
|
||||||
|
} else {
|
||||||
|
alert('Cancelled.');
|
||||||
|
}
|
||||||
|
}, {scope: 'email'});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<a href="#" onclick="fb_login();">Facebook Connect Button (Dialog)</a>
|
||||||
|
|
||||||
{% if error %}
|
{% if error %}
|
||||||
{{ error.messageKey|trans(error.messageData, 'security') }}
|
{{ error.messageKey|trans(error.messageData, 'security') }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -12,11 +52,11 @@
|
|||||||
|
|
||||||
<input type="text" id="username" name="_username" value="{{ last_username }}"
|
<input type="text" id="username" name="_username" value="{{ last_username }}"
|
||||||
placeholder="{{ 'security.login.username'|trans }}"
|
placeholder="{{ 'security.login.username'|trans }}"
|
||||||
required="required" autofocus/>
|
autofocus/>
|
||||||
|
|
||||||
<input type="password" id="password" name="_password"
|
<input type="password" id="password" name="_password"
|
||||||
placeholder="{{ 'security.login.password'|trans }}"
|
placeholder="{{ 'security.login.password'|trans }}"
|
||||||
required="required"/>
|
/>
|
||||||
|
|
||||||
<input type="checkbox" id="remember_me" name="_remember_me" value="on"/>
|
<input type="checkbox" id="remember_me" name="_remember_me" value="on"/>
|
||||||
<label for="remember_me">{{ 'security.login.remember_me'|trans }}</label>
|
<label for="remember_me">{{ 'security.login.remember_me'|trans }}</label>
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Jotunheimr\UserBundle\Security\Core\User;
|
||||||
|
|
||||||
|
use HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface;
|
||||||
|
use HWI\Bundle\OAuthBundle\Security\Core\User\FOSUBUserProvider as BaseFOSUBProvider;
|
||||||
|
use Jotunheimr\UserBundle\Entity\User;
|
||||||
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
|
|
||||||
|
class MyFOSUBUserProvider extends BaseFOSUBProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function connect(UserInterface $user, UserResponseInterface $response)
|
||||||
|
{
|
||||||
|
$property = $this->getProperty($response);
|
||||||
|
$username = $response->getUsername();
|
||||||
|
|
||||||
|
$existingUser = $this->userManager->findUserBy(array($property => $username));
|
||||||
|
|
||||||
|
if (null !== $existingUser) {
|
||||||
|
$this->userManager->updateUser($existingUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->userManager->updateUser($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function loadUserByOAuthUserResponse(UserResponseInterface $response)
|
||||||
|
{
|
||||||
|
$userEmail = $response->getEmail();
|
||||||
|
$user = $this->userManager->findUserByEmail($userEmail);
|
||||||
|
|
||||||
|
if (null === $user) {
|
||||||
|
$username = $response->getRealName();
|
||||||
|
$user = new User();
|
||||||
|
$user->setUsername($username);
|
||||||
|
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
$serviceName = $response->getResourceOwner()->getName();
|
||||||
|
$setter = 'set' . ucfirst($serviceName) . 'AccessToken';
|
||||||
|
$user->$setter($response->getAccessToken());
|
||||||
|
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1 +1,5 @@
|
|||||||
Bazmeg index.
|
{% extends "::base.html.twig" %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
Bazmeg index.
|
||||||
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user