diff --git a/app/SymfonyRequirements.php b/app/SymfonyRequirements.php
index fb70f803..0f899962 100755
--- a/app/SymfonyRequirements.php
+++ b/app/SymfonyRequirements.php
@@ -578,8 +578,8 @@ function_exists('simplexml_import_dom'),
$this->addRecommendation(
class_exists('DomDocument'),
- 'PHP-XML module should be installed',
- 'Install and enable the PHP-XML module.'
+ 'PHP-DOM and PHP-XML modules should be installed',
+ 'Install and enable the PHP-DOM and the PHP-XML modules.'
);
$this->addRecommendation(
diff --git a/app/config/config.yml b/app/config/config.yml
index 419a6206..fa2b1f2f 100644
--- a/app/config/config.yml
+++ b/app/config/config.yml
@@ -5,6 +5,7 @@ imports:
- { resource: jms_serializer.yml }
- { resource: twig.yml }
- { resource: liip_imagine.yml }
+ - { resource: service.yml }
framework:
#esi: ~
@@ -108,9 +109,9 @@ fos_rest:
nelmio_api_doc: CheDream
hwi_oauth:
- connect:
- account_connector: geekhub.user.dream_user_provider
- confirmation: false
+# connect:
+# account_connector: geekhub.user.dream_user_provider
+# confirmation: false
# name of the firewall in which this bundle is active, this setting MUST be set
firewall_name: main
fosub:
@@ -118,26 +119,28 @@ hwi_oauth:
properties:
# these properties will be used/redefined later in the custom FOSUBUserProvider service.
facebook: facebook_id
- vkontakte: vkontakte_id
- odnoklassniki: odnoklassniki_id
+# vkontakte: vkontakte_id
+# odnoklassniki: odnoklassniki_id
resource_owners:
facebook:
type: facebook
client_id: "%facebook_app_id%"
client_secret: "%facebook_app_secret%"
scope: "email, user_photos, user_website, user_birthday"
- vkontakte:
- type: vkontakte
- client_id: "%vkontakte_app_id%"
- client_secret: "%vkontakte_app_secret%"
- scope: "photos"
- odnoklassniki:
- type: odnoklassniki
- client_id: "%odnoklassniki_app_id%"
- client_secret: "%odnoklassniki_app_secret%"
- scope: "VALUABLE_ACCESS;PHOTO CONTENT"
options:
- application_key: "%odnoklassniki_app_key%"
+ display: popup
+# vkontakte:
+# type: vkontakte
+# client_id: "%vkontakte_app_id%"
+# client_secret: "%vkontakte_app_secret%"
+# scope: "photos"
+# odnoklassniki:
+# type: odnoklassniki
+# client_id: "%odnoklassniki_app_id%"
+# client_secret: "%odnoklassniki_app_secret%"
+# scope: "VALUABLE_ACCESS;PHOTO CONTENT"
+# options:
+# application_key: "%odnoklassniki_app_key%"
geekhub_user:
image:
diff --git a/app/config/routing_api.yml b/app/config/routing_api.yml
index 182f36fc..a20c8a36 100644
--- a/app/config/routing_api.yml
+++ b/app/config/routing_api.yml
@@ -14,3 +14,13 @@ faq:
type: rest
resource: "@GeekhubResourceBundle/Controller/Api/FaqController.php"
+hwi_oauth_login:
+ resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
+ prefix: /login
+
+hwi_oauth_redirect:
+ resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
+ prefix: /connect
+
+facebook_login:
+ pattern: /login/check-facebook
\ No newline at end of file
diff --git a/app/config/security.yml b/app/config/security.yml
index a2743685..945314ef 100755
--- a/app/config/security.yml
+++ b/app/config/security.yml
@@ -12,6 +12,8 @@ security:
id: fos_user.user_provider.username
my_custom_hwi_provider:
id: geekhub.user.dream_user_provider
+ _hwi_provider:
+ id: aouth_user_provider
firewalls:
main:
@@ -25,19 +27,20 @@ security:
path: /logout
target: /
anonymous: true
+
oauth:
resource_owners:
- facebook: "/login-social/check-facebook"
- vkontakte: "/login-social/check-vkontakte"
- odnoklassniki: "/login-social/check-odnoklassniki"
- login_path: /
- failure_path: /nologin
+ facebook: "/login/check-facebook"
+ login_path: /login
+ failure_path: /login
oauth_user_provider:
- service: geekhub.user.dream_user_provider
+ service: aouth_user_provider
+ anonymous: true
access_control:
- - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
+ - { path: ^/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
+ - { path: ^/connect, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: [ROLE_MODERATOR, ROLE_SUPER_ADMIN]}
- { path: ^/dream/edit, role: ROLE_USER }
diff --git a/app/config/service.yml b/app/config/service.yml
new file mode 100644
index 00000000..de05de6e
--- /dev/null
+++ b/app/config/service.yml
@@ -0,0 +1,16 @@
+# Learn more about services, parameters and containers at
+# http://symfony.com/doc/current/book/service_container.html
+parameters:
+# parameter_name: value
+
+ user_class_name: Geekhub\UserBundle\Entity\User
+
+services:
+# service_name:
+# class: AppBundle\Directory\ClassName
+# arguments: ["@another_service_name", "plain_value", "%parameter_name%"]
+ aouth_user_provider:
+ class: Geekhub\UserBundle\Model\OAuthUserProvider
+ arguments:
+ - @doctrine
+ - %user_class_name%
diff --git a/composer.lock b/composer.lock
index c34b2a42..53c28a8d 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "10fbb5e60c9dffb0233eb746b72a4d9f",
+ "hash": "4ccd14728b4258e679c25c0373eef8ee",
"packages": [
{
"name": "ahmedsamy/hype-mailchimp-bundle",
@@ -391,7 +391,7 @@
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com",
- "homepage": "https://github.com/schmittjoh",
+ "homepage": "http://jmsyst.com",
"role": "Developer of wrapped JMSSerializerBundle"
}
],
@@ -1147,7 +1147,7 @@
"homepage": "https://github.com/friendsofsymfony/FOSJsRoutingBundle/contributors"
},
{
- "name": "William DURAND",
+ "name": "William Durand",
"email": "william.durand1@gmail.com"
}
],
@@ -1619,6 +1619,115 @@
],
"time": "2015-03-18 18:23:50"
},
+ {
+ "name": "guzzlehttp/guzzle",
+ "version": "5.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/guzzle/guzzle.git",
+ "reference": "475b29ccd411f2fa8a408e64576418728c032cfa"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/475b29ccd411f2fa8a408e64576418728c032cfa",
+ "reference": "475b29ccd411f2fa8a408e64576418728c032cfa",
+ "shasum": ""
+ },
+ "require": {
+ "guzzlehttp/ringphp": "~1.0",
+ "php": ">=5.4.0"
+ },
+ "require-dev": {
+ "ext-curl": "*",
+ "phpunit/phpunit": "~4.0",
+ "psr/log": "~1.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "5.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "GuzzleHttp\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ }
+ ],
+ "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients",
+ "homepage": "http://guzzlephp.org/",
+ "keywords": [
+ "client",
+ "curl",
+ "framework",
+ "http",
+ "http client",
+ "rest",
+ "web service"
+ ],
+ "time": "2015-01-28 01:03:29"
+ },
+ {
+ "name": "guzzlehttp/ringphp",
+ "version": "1.0.7",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/guzzle/RingPHP.git",
+ "reference": "52d868f13570a9a56e5fce6614e0ec75d0f13ac2"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/52d868f13570a9a56e5fce6614e0ec75d0f13ac2",
+ "reference": "52d868f13570a9a56e5fce6614e0ec75d0f13ac2",
+ "shasum": ""
+ },
+ "require": {
+ "guzzlehttp/streams": "~3.0",
+ "php": ">=5.4.0",
+ "react/promise": "~2.0"
+ },
+ "require-dev": {
+ "ext-curl": "*",
+ "phpunit/phpunit": "~4.0"
+ },
+ "suggest": {
+ "ext-curl": "Guzzle will use specific adapters if cURL is present"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "GuzzleHttp\\Ring\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ }
+ ],
+ "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.",
+ "time": "2015-03-30 01:43:20"
+ },
{
"name": "guzzlehttp/streams",
"version": "dev-master",
@@ -2128,7 +2237,7 @@
],
"authors": [
{
- "name": "Johannes Schmitt",
+ "name": "Johannes M. Schmitt",
"email": "schmittjoh@gmail.com",
"homepage": "https://github.com/schmittjoh",
"role": "Developer of wrapped JMSSerializerBundle"
@@ -2198,9 +2307,9 @@
],
"authors": [
{
- "name": "Johannes Schmitt",
+ "name": "Johannes M. Schmitt",
"email": "schmittjoh@gmail.com",
- "homepage": "https://github.com/schmittjoh",
+ "homepage": "http://jmsyst.com",
"role": "Developer of wrapped JMSSerializerBundle"
}
],
@@ -2347,7 +2456,7 @@
"email": "stof@notk.org"
},
{
- "name": "KnpLabs",
+ "name": "Knplabs",
"homepage": "http://knplabs.com"
},
{
@@ -2594,6 +2703,78 @@
],
"time": "2014-03-23 14:00:21"
},
+ {
+ "name": "liip/monitor-bundle",
+ "version": "2.0.8",
+ "target-dir": "Liip/MonitorBundle",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/liip/LiipMonitorBundle.git",
+ "reference": "5d0a66c3e071c57348d8d0d9ab1214e2437f4b6c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/liip/LiipMonitorBundle/zipball/5d0a66c3e071c57348d8d0d9ab1214e2437f4b6c",
+ "reference": "5d0a66c3e071c57348d8d0d9ab1214e2437f4b6c",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3",
+ "symfony/framework-bundle": "~2.3",
+ "zendframework/zenddiagnostics": "~1.0.2|~1.1"
+ },
+ "require-dev": {
+ "guzzle/guzzle": "~3.8",
+ "matthiasnoback/symfony-dependency-injection-test": "~0.4",
+ "sensiolabs/security-checker": "~1.3",
+ "symfony/expression-language": "~2.3"
+ },
+ "suggest": {
+ "sensio/distribution-bundle": "To be able to use the composer ScriptHandler",
+ "symfony/expression-language": "To use the Expression check"
+ },
+ "type": "symfony-bundle",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Liip\\MonitorBundle": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Liip AG",
+ "homepage": "http://www.liip.ch/"
+ },
+ {
+ "name": "Alvaro Videla",
+ "email": "alvaro.videla@liip.ch"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://github.com/liip/LiipMonitorBundle/contributors"
+ },
+ {
+ "name": "Kevin Bond",
+ "homepage": "http://zenstruck.com/"
+ }
+ ],
+ "description": "Liip Monitor Bundle",
+ "keywords": [
+ "check",
+ "health",
+ "monitor",
+ "monitoring"
+ ],
+ "time": "2015-03-17 20:48:22"
+ },
{
"name": "mandrill/mandrill",
"version": "1.0.54",
@@ -2955,9 +3136,9 @@
],
"authors": [
{
- "name": "Johannes Schmitt",
+ "name": "Johannes M. Schmitt",
"email": "schmittjoh@gmail.com",
- "homepage": "https://github.com/schmittjoh",
+ "homepage": "http://jmsyst.com",
"role": "Developer of wrapped JMSSerializerBundle"
}
],
@@ -3005,9 +3186,9 @@
],
"authors": [
{
- "name": "Johannes Schmitt",
+ "name": "Johannes M. Schmitt",
"email": "schmittjoh@gmail.com",
- "homepage": "https://github.com/schmittjoh",
+ "homepage": "http://jmsyst.com",
"role": "Developer of wrapped JMSSerializerBundle"
}
],
@@ -3058,6 +3239,50 @@
],
"time": "2012-12-21 11:40:51"
},
+ {
+ "name": "react/promise",
+ "version": "v2.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/reactphp/promise.git",
+ "reference": "365fcee430dfa4ace1fbc75737ca60ceea7eeeef"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/reactphp/promise/zipball/365fcee430dfa4ace1fbc75737ca60ceea7eeeef",
+ "reference": "365fcee430dfa4ace1fbc75737ca60ceea7eeeef",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.4.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "React\\Promise\\": "src/"
+ },
+ "files": [
+ "src/functions_include.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Jan Sorgalla",
+ "email": "jsorgalla@googlemail.com"
+ }
+ ],
+ "description": "A lightweight implementation of CommonJS Promises/A for PHP",
+ "time": "2014-12-30 13:32:42"
+ },
{
"name": "sensio/distribution-bundle",
"version": "v2.3.11",
@@ -3207,6 +3432,51 @@
"description": "This bundle generates code for you",
"time": "2015-03-17 06:36:52"
},
+ {
+ "name": "sensiolabs/security-checker",
+ "version": "dev-master",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sensiolabs/security-checker.git",
+ "reference": "134cecf1c61256bd8e973e11376891a724543820"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sensiolabs/security-checker/zipball/134cecf1c61256bd8e973e11376891a724543820",
+ "reference": "134cecf1c61256bd8e973e11376891a724543820",
+ "shasum": ""
+ },
+ "require": {
+ "ext-curl": "*",
+ "symfony/console": "~2.0"
+ },
+ "bin": [
+ "security-checker"
+ ],
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "SensioLabs\\Security": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien.potencier@gmail.com"
+ }
+ ],
+ "description": "A security checker for your composer.lock",
+ "time": "2015-01-26 16:25:19"
+ },
{
"name": "sonata-project/admin-bundle",
"version": "2.3.2",
@@ -4658,6 +4928,65 @@
"negotiation"
],
"time": "2014-10-02 07:26:00"
+ },
+ {
+ "name": "zendframework/zenddiagnostics",
+ "version": "v1.0.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/zendframework/ZendDiagnostics.git",
+ "reference": "b855b48f6539038270a3c0935b6bd2c51fa43f7c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/zendframework/ZendDiagnostics/zipball/b855b48f6539038270a3c0935b6bd2c51fa43f7c",
+ "reference": "b855b48f6539038270a3c0935b6bd2c51fa43f7c",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "require-dev": {
+ "guzzle/http": "3.*",
+ "guzzle/plugin-mock": "3.*",
+ "predis/predis": "0.8.*",
+ "sensiolabs/security-checker": "1.3.*@dev",
+ "symfony/yaml": "v2.3.11",
+ "videlalvaro/php-amqplib": "2.*",
+ "zendframework/zend-loader": "2.*"
+ },
+ "suggest": {
+ "ext-bcmath": "Required by Check\\CpuPerformance",
+ "guzzle/http": "Required by Check\\GuzzleHttpService",
+ "predis/predis": "Required by Check\\Redis",
+ "sensiolabs/security-checker": "Required by Check\\SecurityAdvisory",
+ "symfony/yaml": "Required by Check\\YamlFile",
+ "videlalvaro/php-amqplib": "Required by Check\\RabbitMQ"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "ZendDiagnostics\\": "src/",
+ "ZendDiagnosticsTest\\": "tests/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "description": "A set of components for performing diagnostic tests in PHP applications",
+ "homepage": "https://github.com/zendframework/ZendDiagnostics",
+ "keywords": [
+ "diagnostics",
+ "php",
+ "test"
+ ],
+ "time": "2014-12-07 18:10:07"
}
],
"packages-dev": [
@@ -5533,6 +5862,7 @@
"hipaway-travel/mandrill-bundle": 20,
"ahmedsamy/hype-mailchimp-bundle": 20,
"geek-hub/domain-routing-bundle": 20,
+ "sensiolabs/security-checker": 20,
"behat/behat": 0,
"behat/mink": 0,
"behat/symfony2-extension": 0,
@@ -5541,7 +5871,6 @@
"behat/mink-browserkit-driver": 0
},
"prefer-stable": false,
- "prefer-lowest": false,
"platform": {
"php": ">=5.3.3"
},
diff --git a/src/Geekhub/ResourceBundle/Resources/views/Email/registration.html.twig b/src/Geekhub/ResourceBundle/Resources/views/Email/registration.html.twig
index c7c11eb8..694bde34 100644
--- a/src/Geekhub/ResourceBundle/Resources/views/Email/registration.html.twig
+++ b/src/Geekhub/ResourceBundle/Resources/views/Email/registration.html.twig
@@ -3,7 +3,7 @@
{% block header %}
Щиро вітаємо у
-
+
@@ -25,31 +25,31 @@
підключено через
{% if user.facebookId is not null %}
Facebook
- {% elseif user.odnoklassnikiId %}
- Однокласники
- {% elseif user.vkontakteId %}
- ВКонтакте
+ {#{% elseif user.odnoklassnikiId %}#}
+ {#Однокласники#}
+ {#{% elseif user.vkontakteId %}#}
+ {#ВКонтакте#}
{% endif %}
-
+ {##}
+ {#
Що далі?
#}
+ {#
#}
+ {#
#}
{% endblock content %}
diff --git a/src/Geekhub/UserBundle/Entity/User.php b/src/Geekhub/UserBundle/Entity/User.php
index 5ac53fa2..7b494fa4 100644
--- a/src/Geekhub/UserBundle/Entity/User.php
+++ b/src/Geekhub/UserBundle/Entity/User.php
@@ -6,6 +6,7 @@
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;
+use Symfony\Component\Security\Core\User\UserInterface;
/**
* Users
@@ -13,7 +14,7 @@
* @ORM\Table(name="users")
* @ORM\Entity(repositoryClass="Geekhub\UserBundle\Entity\UsersRepository")
*/
-class User extends BaseUser //implements DreamUserInterface
+class User extends BaseUser implements UserInterface, \Serializable//implements DreamUserInterface
{
use ContactsInfo;
@@ -28,12 +29,58 @@ class User extends BaseUser //implements DreamUserInterface
*/
protected $id;
+// /**
+// * @ORM\Column(type="string", length=25, unique=true)
+// */
+// protected $username;
+
+ /**
+ * @ORM\Column(type="string", length=25, nullable=true)
+ */
+ private $resourceUsername;
+
+ /**
+ * @ORM\Column(type="string", length=25, nullable=true)
+ */
+ private $realname;
+
+// /**
+// * @ORM\Column(type="string", length=64, nullable=true)
+// */
+// protected $password;
+
+// /**
+// * @ORM\Column(type="string", length=100, unique=true)
+// */
+// protected $email;
+
+// /**
+// * @ORM\Column(type="string", length=100, unique=false)
+// */
+// protected $salt;
+
+// /**
+// * @ORM\Column(name="is_active", type="boolean")
+// */
+// private $isActive;
+
+ /**
+ * @ORM\Column(type="string", length=100)
+ */
+ private $resource;
+
+// /**
+// * @ORM\Column(type="datetime")
+// */
+// private $lastLogin;
+
/**
* @var string
*
* @Assert\NotBlank()
* @ORM\Column(name="firstName", type="string", length=50, nullable=true)
*/
+
protected $firstName;
/**
@@ -41,6 +88,7 @@ class User extends BaseUser //implements DreamUserInterface
*
* @ORM\Column(name="middleName", type="string", length=50, nullable=true)
*/
+
protected $middleName;
/**
@@ -62,19 +110,19 @@ class User extends BaseUser //implements DreamUserInterface
*/
protected $birthday;
- /**
- * @var string
- *
- * @ORM\Column(name="about", type="text", nullable=true)
- */
- protected $about;
-
- /**
- * @var string
- *
- * @ORM\Column(name="vkontakte_id", type="string", length=45, nullable=true, unique=true)
- */
- protected $vkontakteId;
+// /**
+// * @var string
+// *
+// * @ORM\Column(name="about", type="text", nullable=true)
+// */
+// protected $about;
+//
+// /**
+// * @var string
+// *
+// * @ORM\Column(name="vkontakte_id", type="string", length=45, nullable=true, unique=true)
+// */
+// protected $vkontakteId;
/**
* @var string
@@ -83,42 +131,42 @@ class User extends BaseUser //implements DreamUserInterface
*/
protected $facebookId;
- /**
- * @var string
- *
- * @ORM\Column(name="odnoklassniki_id", type="string", length=45, nullable=true, unique=true)
- */
- protected $odnoklassnikiId;
-
- /**
- * @ORM\ManyToMany(targetEntity="Geekhub\DreamBundle\Entity\Dream", mappedBy="usersWhoFavorites" )
- */
- protected $favoriteDreams;
-
- /**
- * @ORM\OneToMany(targetEntity="Geekhub\DreamBundle\Entity\FinancialContribute", mappedBy="user")
- */
- protected $financialContributions;
-
- /**
- * @ORM\OneToMany(targetEntity="Geekhub\DreamBundle\Entity\EquipmentContribute", mappedBy="user")
- */
- protected $equipmentContributions;
-
- /**
- * @ORM\OneToMany(targetEntity="Geekhub\DreamBundle\Entity\WorkContribute", mappedBy="user")
- */
- protected $workContributions;
-
- /**
- * @ORM\OneToMany(targetEntity="Geekhub\DreamBundle\Entity\OtherContribute", mappedBy="user")
- */
- protected $otherContributions;
-
- /**
- * @ORM\OneToMany(targetEntity="Geekhub\DreamBundle\Entity\Dream", mappedBy="author")
- */
- protected $dreams;
+// /**
+// * @var string
+// *
+// * @ORM\Column(name="odnoklassniki_id", type="string", length=45, nullable=true, unique=true)
+// */
+// protected $odnoklassnikiId;
+//
+// /**
+// * @ORM\ManyToMany(targetEntity="Geekhub\DreamBundle\Entity\Dream", mappedBy="usersWhoFavorites" )
+// */
+// protected $favoriteDreams;
+//
+// /**
+// * @ORM\OneToMany(targetEntity="Geekhub\DreamBundle\Entity\FinancialContribute", mappedBy="user")
+// */
+// protected $financialContributions;
+//
+// /**
+// * @ORM\OneToMany(targetEntity="Geekhub\DreamBundle\Entity\EquipmentContribute", mappedBy="user")
+// */
+// protected $equipmentContributions;
+//
+// /**
+// * @ORM\OneToMany(targetEntity="Geekhub\DreamBundle\Entity\WorkContribute", mappedBy="user")
+// */
+// protected $workContributions;
+//
+// /**
+// * @ORM\OneToMany(targetEntity="Geekhub\DreamBundle\Entity\OtherContribute", mappedBy="user")
+// */
+// protected $otherContributions;
+//
+// /**
+// * @ORM\OneToMany(targetEntity="Geekhub\DreamBundle\Entity\Dream", mappedBy="author")
+// */
+// protected $dreams;
/**
* Constructor
@@ -132,6 +180,10 @@ public function __construct()
$this->workContributions = new ArrayCollection();
$this->otherContributions = new ArrayCollection();
parent::__construct();
+
+ $this->salt = base_convert(sha1(uniqid(mt_rand(), true)), 16, 36);
+ $this->roles = array();
+ $this->setIsActive(true);
}
/**
@@ -571,4 +623,188 @@ public function isFakeEmail()
{
return false === strpos($this->email, self::FAKE_EMAIL_PART) && $this->email ? false : true;
}
+
+ /**
+ * Set username
+ *
+ * @param string $username
+ * @return User
+ */
+ public function setUsername($username)
+ {
+ $this->username = $username;
+
+ return $this;
+ }
+
+ /**
+ * Get username
+ *
+ * @return string
+ */
+ public function getUsername()
+ {
+ return $this->username;
+ }
+
+ /**
+ * Set resourceUsername
+ *
+ * @param string $resourceUsername
+ * @return User
+ */
+ public function setResourceUsername($resourceUsername)
+ {
+ $this->resourceUsername = $resourceUsername;
+
+ return $this;
+ }
+
+ /**
+ * Get resourceUsername
+ *
+ * @return string
+ */
+ public function getResourceUsername()
+ {
+ return $this->resourceUsername;
+ }
+
+ /**
+ * Set realname
+ *
+ * @param string $realname
+ * @return User
+ */
+ public function setRealname($realname)
+ {
+ $this->realname = $realname;
+
+ return $this;
+ }
+
+ /**
+ * Get realname
+ *
+ * @return string
+ */
+ public function getRealname()
+ {
+ return $this->realname;
+ }
+
+ /**
+ * Set password
+ *
+ * @param string $password
+ * @return User
+ */
+ public function setPassword($password)
+ {
+ $this->password = $password;
+
+ return $this;
+ }
+
+ /**
+ * Get password
+ *
+ * @return string
+ */
+ public function getPassword()
+ {
+ return $this->password;
+ }
+
+ /**
+ * Set email
+ *
+ * @param string $email
+ * @return User
+ */
+ public function setEmail($email)
+ {
+ $this->email = $email;
+
+ return $this;
+ }
+
+ /**
+ * Get email
+ *
+ * @return string
+ */
+ public function getEmail()
+ {
+ return $this->email;
+ }
+
+ /**
+ * Set salt
+ *
+ * @param string $salt
+ * @return User
+ */
+ public function setSalt($salt)
+ {
+ $this->salt = $salt;
+
+ return $this;
+ }
+
+ /**
+ * Get salt
+ *
+ * @return string
+ */
+ public function getSalt()
+ {
+ return $this->salt;
+ }
+
+ /**
+ * Set isActive
+ *
+ * @param boolean $isActive
+ * @return User
+ */
+ public function setIsActive($isActive)
+ {
+ $this->isActive = $isActive;
+
+ return $this;
+ }
+
+ /**
+ * Get isActive
+ *
+ * @return boolean
+ */
+ public function getIsActive()
+ {
+ return $this->isActive;
+ }
+
+ /**
+ * Set resource
+ *
+ * @param string $resource
+ * @return User
+ */
+ public function setResource($resource)
+ {
+ $this->resource = $resource;
+
+ return $this;
+ }
+
+ /**
+ * Get resource
+ *
+ * @return string
+ */
+ public function getResource()
+ {
+ return $this->resource;
+ }
}
diff --git a/src/Geekhub/UserBundle/Model/OAuthUserProvider.php b/src/Geekhub/UserBundle/Model/OAuthUserProvider.php
new file mode 100644
index 00000000..715991cc
--- /dev/null
+++ b/src/Geekhub/UserBundle/Model/OAuthUserProvider.php
@@ -0,0 +1,80 @@
+em = $registry->getManager();
+ $this->repository = $this->em->getRepository($className);
+ $this->className = $className;
+ }
+
+ public function loadUserByOAuthUserResponse(UserResponseInterface $response) {
+ $username = $response->getUsername();
+ $nickname = $response->getNickname();
+ $realname = $response->getRealName();
+ $email = $response->getEmail();
+
+ $resourceOwnerName = $response->getResourceOwner()->getName();
+
+ $user = $this->repository->findOneBy(
+ array('resource' => $resourceOwnerName, 'username' => $nickname)
+ );
+
+ if (null === $user) {
+ $user = new $this->className();
+ $user->setUsername($nickname);
+ $user->setResourceUsername($username);
+ $user->setResource($resourceOwnerName);
+ $user->setRealname($realname);
+ $user->setEmail($email);
+ $user->setLastLogin(new \DateTime());
+ $this->em->persist($user);
+ $id = $this->em->flush();
+
+ }
+
+ return $user;
+ }
+
+ public function loadUserByUsername($username) {
+
+ $user = $this->repository->findOneBy(array('username' => $username));
+ if (!$user) {
+ throw new UsernameNotFoundException(sprintf("User '%s' not found.", $username));
+ }
+
+ return $user;
+ }
+
+ public function refreshUser(UserInterface $user) {
+ return $this->loadUserByUsername($user->getUsername());
+ }
+
+ public function supportsClass($class)
+ {
+ return $class === $this->class || is_subclass_of($class, $this->class);
+ }
+}
\ No newline at end of file