| =
From 7df63184a6e464e2d173a8f5708a75df7b2f28ab Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Mon, 21 Sep 2015 15:13:39 +0000
Subject: [PATCH 0172/1397] check object property exists before read
---
src/Controller/Traits/LoginTrait.php | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/Controller/Traits/LoginTrait.php b/src/Controller/Traits/LoginTrait.php
index d29977610..88e86980e 100644
--- a/src/Controller/Traits/LoginTrait.php
+++ b/src/Controller/Traits/LoginTrait.php
@@ -80,8 +80,11 @@ protected function _afterIdentifyUser($user, $socialLogin = false)
} else {
$message = __d('Users', 'Username or password is incorrect');
if ($socialLogin) {
- $socialData = $this->request->session()->check($socialKey);
- $socialDataEmail = Hash::get((array)$socialData->info, Configure::read('data_email_key'));
+ $socialData = $this->request->session()->read($socialKey);
+ $socialDataEmail = null;
+ if (!empty($socialData->info)) {
+ $socialDataEmail = Hash::get((array)$socialData->info, Configure::read('data_email_key'));
+ }
$postedEmail = $this->request->data(Configure::read('Users.Key.Data.email'));
if (Configure::read('Users.Email.required') &&
empty($socialDataEmail) &&
@@ -90,9 +93,8 @@ protected function _afterIdentifyUser($user, $socialLogin = false)
'controller' => 'Users',
'action' => 'socialEmail'
]);
- } else {
- $message = __d('Users', 'There was an error associating your social network account');
}
+ $message = __d('Users', 'There was an error associating your social network account');
}
$this->Flash->error($message, 'default', [], 'auth');
}
From 5b62c19f07e553ffda639acb0bbaf66649f4c63e Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Tue, 22 Sep 2015 00:57:30 +0000
Subject: [PATCH 0173/1397] use real uuids in tests too
---
tests/Fixture/SocialAccountsFixture.php | 20 ++++++++--------
tests/Fixture/UsersFixture.php | 20 ++++++++--------
.../Auth/RememberMeAuthenticateTest.php | 2 +-
.../Controller/Traits/BaseTraitTest.php | 4 ++--
.../Traits/PasswordManagementTraitTest.php | 10 ++++----
.../Controller/Traits/SimpleCrudTraitTest.php | 24 +++++++++----------
.../Model/Behavior/RegisterBehaviorTest.php | 4 ++--
.../Behavior/SocialAccountBehaviorTest.php | 4 ++--
tests/TestCase/Model/Table/UsersTableTest.php | 2 +-
9 files changed, 45 insertions(+), 45 deletions(-)
diff --git a/tests/Fixture/SocialAccountsFixture.php b/tests/Fixture/SocialAccountsFixture.php
index 838d3ba0c..19fdbde4e 100644
--- a/tests/Fixture/SocialAccountsFixture.php
+++ b/tests/Fixture/SocialAccountsFixture.php
@@ -48,8 +48,8 @@ class SocialAccountsFixture extends TestFixture
*/
public $records = [
[
- 'id' => 1,
- 'user_id' => 1,
+ 'id' => '00000000-0000-0000-0000-000000000001',
+ 'user_id' => '00000000-0000-0000-0000-000000000001',
'provider' => 'Facebook',
'username' => 'user-1-fb',
'reference' => 'reference-1-1234',
@@ -64,8 +64,8 @@ class SocialAccountsFixture extends TestFixture
'modified' => '2015-05-22 21:52:44'
],
[
- 'id' => 2,
- 'user_id' => 1,
+ 'id' => '00000000-0000-0000-0000-000000000002',
+ 'user_id' => '00000000-0000-0000-0000-000000000001',
'provider' => 'Twitter',
'username' => 'user-1-tw',
'reference' => 'reference-1-1234',
@@ -80,8 +80,8 @@ class SocialAccountsFixture extends TestFixture
'modified' => '2015-05-22 21:52:44'
],
[
- 'id' => 3,
- 'user_id' => 2,
+ 'id' => '00000000-0000-0000-0000-000000000003',
+ 'user_id' => '00000000-0000-0000-0000-000000000002',
'provider' => 'Facebook',
'username' => 'user-2-fb',
'reference' => 'reference-2-1',
@@ -96,8 +96,8 @@ class SocialAccountsFixture extends TestFixture
'modified' => '2015-05-22 21:52:44'
],
[
- 'id' => 4,
- 'user_id' => 3,
+ 'id' => '00000000-0000-0000-0000-000000000004',
+ 'user_id' => '00000000-0000-0000-0000-000000000003',
'provider' => 'Twitter',
'username' => 'user-2-tw',
'reference' => 'reference-2-2',
@@ -112,8 +112,8 @@ class SocialAccountsFixture extends TestFixture
'modified' => '2015-05-22 21:52:44'
],
[
- 'id' => 5,
- 'user_id' => 4,
+ 'id' => '00000000-0000-0000-0000-000000000005',
+ 'user_id' => '00000000-0000-0000-0000-000000000004',
'provider' => 'Twitter',
'username' => 'user-2-tw',
'reference' => 'reference-2-2',
diff --git a/tests/Fixture/UsersFixture.php b/tests/Fixture/UsersFixture.php
index 296ce4d22..8ba1b1d9a 100644
--- a/tests/Fixture/UsersFixture.php
+++ b/tests/Fixture/UsersFixture.php
@@ -60,7 +60,7 @@ class UsersFixture extends TestFixture
*/
public $records = [
[
- 'id' => 1,
+ 'id' => '00000000-0000-0000-0000-000000000001',
'username' => 'user-1',
'email' => 'user-1@test.com',
'password' => '12345',
@@ -78,7 +78,7 @@ class UsersFixture extends TestFixture
'modified' => '2015-06-24 17:33:54'
],
[
- 'id' => 2,
+ 'id' => '00000000-0000-0000-0000-000000000002',
'username' => 'user-2',
'email' => 'user-2@test.com',
'password' => '12345',
@@ -96,7 +96,7 @@ class UsersFixture extends TestFixture
'modified' => '2015-06-24 17:33:54'
],
[
- 'id' => 3,
+ 'id' => '00000000-0000-0000-0000-000000000003',
'username' => 'user-3',
'email' => 'user-3@test.com',
'password' => '12345',
@@ -114,7 +114,7 @@ class UsersFixture extends TestFixture
'modified' => '2015-06-24 17:33:54'
],
[
- 'id' => 4,
+ 'id' => '00000000-0000-0000-0000-000000000004',
'username' => 'user-4',
'email' => '4@example.com',
'password' => 'Lorem ipsum dolor sit amet',
@@ -132,7 +132,7 @@ class UsersFixture extends TestFixture
'modified' => '2015-06-24 17:33:54'
],
[
- 'id' => 5,
+ 'id' => '00000000-0000-0000-0000-000000000005',
'username' => 'user-5',
'email' => 'test@example.com',
'password' => '12345',
@@ -150,7 +150,7 @@ class UsersFixture extends TestFixture
'modified' => '2015-06-24 17:33:54'
],
[
- 'id' => 6,
+ 'id' => '00000000-0000-0000-0000-000000000006',
'username' => 'Lorem ipsum dolor sit amet',
'email' => 'Lorem ipsum dolor sit amet',
'password' => 'Lorem ipsum dolor sit amet',
@@ -168,7 +168,7 @@ class UsersFixture extends TestFixture
'modified' => '2015-06-24 17:33:54'
],
[
- 'id' => 7,
+ 'id' => '00000000-0000-0000-0000-000000000007',
'username' => 'Lorem ipsum dolor sit amet',
'email' => 'Lorem ipsum dolor sit amet',
'password' => 'Lorem ipsum dolor sit amet',
@@ -186,7 +186,7 @@ class UsersFixture extends TestFixture
'modified' => '2015-06-24 17:33:54'
],
[
- 'id' => 8,
+ 'id' => '00000000-0000-0000-0000-000000000008',
'username' => 'Lorem ipsum dolor sit amet',
'email' => 'Lorem ipsum dolor sit amet',
'password' => 'Lorem ipsum dolor sit amet',
@@ -204,7 +204,7 @@ class UsersFixture extends TestFixture
'modified' => '2015-06-24 17:33:54'
],
[
- 'id' => 9,
+ 'id' => '00000000-0000-0000-0000-000000000009',
'username' => 'Lorem ipsum dolor sit amet',
'email' => 'Lorem ipsum dolor sit amet',
'password' => 'Lorem ipsum dolor sit amet',
@@ -222,7 +222,7 @@ class UsersFixture extends TestFixture
'modified' => '2015-06-24 17:33:54'
],
[
- 'id' => 10,
+ 'id' => '00000000-0000-0000-0000-000000000010',
'username' => 'Lorem ipsum dolor sit amet',
'email' => 'Lorem ipsum dolor sit amet',
'password' => 'Lorem ipsum dolor sit amet',
diff --git a/tests/TestCase/Auth/RememberMeAuthenticateTest.php b/tests/TestCase/Auth/RememberMeAuthenticateTest.php
index 1d121c697..8e3b5d6ca 100644
--- a/tests/TestCase/Auth/RememberMeAuthenticateTest.php
+++ b/tests/TestCase/Auth/RememberMeAuthenticateTest.php
@@ -82,7 +82,7 @@ public function testAuthenticateHappy()
->method('read')
->with('remember_me')
->will($this->returnValue([
- 'id' => 1,
+ 'id' => '00000000-0000-0000-0000-000000000001',
'user_agent' => 'user-agent'
]));
$registry = new ComponentRegistry($this->controller);
diff --git a/tests/TestCase/Controller/Traits/BaseTraitTest.php b/tests/TestCase/Controller/Traits/BaseTraitTest.php
index e22c44a47..5905c7ee6 100644
--- a/tests/TestCase/Controller/Traits/BaseTraitTest.php
+++ b/tests/TestCase/Controller/Traits/BaseTraitTest.php
@@ -145,7 +145,7 @@ protected function _mockAuthLoggedIn()
->disableOriginalConstructor()
->getMock();
$user = [
- 'id' => 1,
+ 'id' => '00000000-0000-0000-0000-000000000001',
'password' => '12345',
];
$this->Trait->Auth->expects($this->any())
@@ -154,7 +154,7 @@ protected function _mockAuthLoggedIn()
$this->Trait->Auth->expects($this->any())
->method('user')
->with('id')
- ->will($this->returnValue(1));
+ ->will($this->returnValue('00000000-0000-0000-0000-000000000001'));
}
/**
diff --git a/tests/TestCase/Controller/Traits/PasswordManagementTraitTest.php b/tests/TestCase/Controller/Traits/PasswordManagementTraitTest.php
index a3567162a..3c64ebb75 100644
--- a/tests/TestCase/Controller/Traits/PasswordManagementTraitTest.php
+++ b/tests/TestCase/Controller/Traits/PasswordManagementTraitTest.php
@@ -47,7 +47,7 @@ public function tearDown()
*/
public function testChangePasswordHappy()
{
- $this->assertEquals('12345', $this->table->get(1)->password);
+ $this->assertEquals('12345', $this->table->get('00000000-0000-0000-0000-000000000001')->password);
$this->_mockRequestPost();
$this->_mockAuthLoggedIn();
$this->_mockFlash();
@@ -65,7 +65,7 @@ public function testChangePasswordHappy()
->with('Password has been changed successfully');
$this->Trait->changePassword();
$hasher = PasswordHasherFactory::build('Default');
- $this->assertTrue($hasher->check('new', $this->table->get(1)->password));
+ $this->assertTrue($hasher->check('new', $this->table->get('00000000-0000-0000-0000-000000000001')->password));
}
/**
@@ -127,7 +127,7 @@ public function testResetPassword()
*/
public function testRequestResetPasswordGet()
{
- $this->assertEquals('ae93ddbe32664ce7927cf0c5c5a5e59d', $this->table->get(1)->token);
+ $this->assertEquals('ae93ddbe32664ce7927cf0c5c5a5e59d', $this->table->get('00000000-0000-0000-0000-000000000001')->token);
$this->_mockRequestGet();
$this->_mockFlash();
$this->Trait->request->expects($this->never())
@@ -142,7 +142,7 @@ public function testRequestResetPasswordGet()
*/
public function testRequestPasswordHappy()
{
- $this->assertEquals('ae93ddbe32664ce7927cf0c5c5a5e59d', $this->table->get(1)->token);
+ $this->assertEquals('ae93ddbe32664ce7927cf0c5c5a5e59d', $this->table->get('00000000-0000-0000-0000-000000000001')->token);
$this->_mockRequestPost();
$this->_mockAuthLoggedIn();
$this->_mockFlash();
@@ -155,6 +155,6 @@ public function testRequestPasswordHappy()
->method('success')
->with('Password has been changed successfully');
$this->Trait->requestResetPassword();
- $this->assertNotEquals('xxx', $this->table->get(1)->token);
+ $this->assertNotEquals('xxx', $this->table->get('00000000-0000-0000-0000-000000000001')->token);
}
}
diff --git a/tests/TestCase/Controller/Traits/SimpleCrudTraitTest.php b/tests/TestCase/Controller/Traits/SimpleCrudTraitTest.php
index 969ccfdeb..c155947d4 100644
--- a/tests/TestCase/Controller/Traits/SimpleCrudTraitTest.php
+++ b/tests/TestCase/Controller/Traits/SimpleCrudTraitTest.php
@@ -80,7 +80,7 @@ public function testIndex()
*/
public function testView()
{
- $id = 1;
+ $id = '00000000-0000-0000-0000-000000000001';
$this->Trait->view($id);
$expected = [
'Users' => $this->table->get($id),
@@ -195,7 +195,7 @@ public function testAddPostErrors()
*/
public function testEditPostHappy()
{
- $this->assertEquals('user-1@test.com', $this->table->get(1)->email);
+ $this->assertEquals('user-1@test.com', $this->table->get('00000000-0000-0000-0000-000000000001')->email);
$this->_mockRequestPost(['patch', 'post', 'put']);
$this->_mockFlash();
$this->Trait->request->data = [
@@ -206,9 +206,9 @@ public function testEditPostHappy()
->method('success')
->with('The User has been saved');
- $this->Trait->edit(1);
+ $this->Trait->edit('00000000-0000-0000-0000-000000000001');
- $this->assertEquals('newtestuser@test.com', $this->table->get(1)->email);
+ $this->assertEquals('newtestuser@test.com', $this->table->get('00000000-0000-0000-0000-000000000001')->email);
}
/**
@@ -218,7 +218,7 @@ public function testEditPostHappy()
*/
public function testEditPostErrors()
{
- $this->assertEquals('user-1@test.com', $this->table->get(1)->email);
+ $this->assertEquals('user-1@test.com', $this->table->get('00000000-0000-0000-0000-000000000001')->email);
$this->_mockRequestPost(['patch', 'post', 'put']);
$this->_mockFlash();
$this->Trait->request->data = [
@@ -229,9 +229,9 @@ public function testEditPostErrors()
->method('error')
->with('The User could not be saved');
- $this->Trait->edit(1);
+ $this->Trait->edit('00000000-0000-0000-0000-000000000001');
- $this->assertEquals('user-1@test.com', $this->table->get(1)->email);
+ $this->assertEquals('user-1@test.com', $this->table->get('00000000-0000-0000-0000-000000000001')->email);
}
/**
@@ -242,7 +242,7 @@ public function testEditPostErrors()
*/
public function testDeleteHappy()
{
- $this->assertNotEmpty($this->table->get(1));
+ $this->assertNotEmpty($this->table->get('00000000-0000-0000-0000-000000000001'));
$this->_mockRequestPost();
$this->Trait->request->expects($this->any())
->method('allow')
@@ -254,9 +254,9 @@ public function testDeleteHappy()
->method('success')
->with('The User has been deleted');
- $this->Trait->delete(1);
+ $this->Trait->delete('00000000-0000-0000-0000-000000000001');
- $this->table->get(1);
+ $this->table->get('00000000-0000-0000-0000-000000000001');
}
/**
@@ -267,7 +267,7 @@ public function testDeleteHappy()
*/
public function testDeleteNotFound()
{
- $this->assertNotEmpty($this->table->get(1));
+ $this->assertNotEmpty($this->table->get('00000000-0000-0000-0000-000000000001'));
$this->_mockRequestPost();
$this->Trait->request->expects($this->any())
->method('allow')
@@ -276,6 +276,6 @@ public function testDeleteNotFound()
$this->Trait->delete('not-found');
- $this->assertNotEmpty($this->table->get(1));
+ $this->assertNotEmpty($this->table->get('00000000-0000-0000-0000-000000000001'));
}
}
diff --git a/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php b/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php
index 19bb55e2c..79df58c67 100644
--- a/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php
+++ b/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php
@@ -207,7 +207,7 @@ public function testValidateRegisterNoTosRequired()
*/
public function testActivateUser()
{
- $user = $this->Table->find()->where(['id' => 1])->first();
+ $user = $this->Table->find()->where(['id' => '00000000-0000-0000-0000-000000000001'])->first();
$result = $this->Table->activateUser($user);
$this->assertTrue($result->active);
}
@@ -253,7 +253,7 @@ public function testValidateNotExistingUser()
*/
public function testActiveUserRemoveValidationToken()
{
- $user = $this->Table->find()->where(['id' => 1])->first();
+ $user = $this->Table->find()->where(['id' => '00000000-0000-0000-0000-000000000001'])->first();
$this->Behavior = $this->getMockBuilder('CakeDC\Users\Model\Behavior\RegisterBehavior')
->setMethods(['_removeValidationToken'])
->setConstructorArgs([$this->Table])
diff --git a/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php b/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php
index 4e5382595..f6436bc7c 100644
--- a/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php
+++ b/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php
@@ -134,7 +134,7 @@ public function testAfterSaveSocialNotActiveUserNotActive()
public function testAfterSaveSocialActiveUserActive()
{
$event = new Event('eventName');
- $entity = $this->Table->findById(3)->first();
+ $entity = $this->Table->findById('00000000-0000-0000-0000-000000000003')->first();
$this->assertTrue($this->Behavior->afterSave($event, $entity, []));
}
@@ -147,7 +147,7 @@ public function testAfterSaveSocialActiveUserActive()
public function testAfterSaveSocialActiveUserNotActive()
{
$event = new Event('eventName');
- $entity = $this->Table->findById(2)->first();
+ $entity = $this->Table->findById('00000000-0000-0000-0000-000000000002')->first();
$this->assertTrue($this->Behavior->afterSave($event, $entity, []));
}
diff --git a/tests/TestCase/Model/Table/UsersTableTest.php b/tests/TestCase/Model/Table/UsersTableTest.php
index 55a1230e5..3582addd3 100644
--- a/tests/TestCase/Model/Table/UsersTableTest.php
+++ b/tests/TestCase/Model/Table/UsersTableTest.php
@@ -173,7 +173,7 @@ public function testValidateRegisterNoTosRequired()
*/
public function testActivateUser()
{
- $user = $this->Users->find()->where(['id' => 1])->first();
+ $user = $this->Users->find()->where(['id' => '00000000-0000-0000-0000-000000000001'])->first();
$result = $this->Users->activateUser($user);
$this->assertTrue($result->active);
}
From 2be70310765eb52684182c91f47db7fe25f005eb Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Tue, 22 Sep 2015 01:08:13 +0000
Subject: [PATCH 0174/1397] fix uuid types for passing postgresql tests
---
tests/Fixture/SocialAccountsFixture.php | 2 +-
tests/TestCase/Auth/RememberMeAuthenticateTest.php | 5 +++--
tests/TestCase/Controller/Traits/ProfileTraitTest.php | 4 ++--
tests/TestCase/Controller/Traits/SimpleCrudTraitTest.php | 6 ++----
4 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/tests/Fixture/SocialAccountsFixture.php b/tests/Fixture/SocialAccountsFixture.php
index 19fdbde4e..6f3d9dda8 100644
--- a/tests/Fixture/SocialAccountsFixture.php
+++ b/tests/Fixture/SocialAccountsFixture.php
@@ -18,7 +18,7 @@ class SocialAccountsFixture extends TestFixture
// @codingStandardsIgnoreStart
public $fields = [
'id' => ['type' => 'uuid', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null],
- 'user_id' => ['type' => 'string', 'length' => 36, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null],
+ 'user_id' => ['type' => 'uuid', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null],
'provider' => ['type' => 'string', 'length' => 255, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null],
'username' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null],
'reference' => ['type' => 'string', 'length' => 255, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null],
diff --git a/tests/TestCase/Auth/RememberMeAuthenticateTest.php b/tests/TestCase/Auth/RememberMeAuthenticateTest.php
index 8e3b5d6ca..b0d60f4bb 100644
--- a/tests/TestCase/Auth/RememberMeAuthenticateTest.php
+++ b/tests/TestCase/Auth/RememberMeAuthenticateTest.php
@@ -115,7 +115,8 @@ public function testAuthenticateBadUser()
->method('read')
->with('remember_me')
->will($this->returnValue([
- 'id' => 'bad-user',
+ //bad-user
+ 'id' => '00000000-0000-0000-0000-000000000000',
'user_agent' => 'user-agent'
]));
$registry = new ComponentRegistry($this->controller);
@@ -149,7 +150,7 @@ public function testAuthenticateBadAgent()
->method('read')
->with('remember_me')
->will($this->returnValue([
- 'id' => 1,
+ 'id' => '00000000-0000-0000-0000-000000000001',
'user_agent' => 'bad-agent'
]));
$registry = new ComponentRegistry($this->controller);
diff --git a/tests/TestCase/Controller/Traits/ProfileTraitTest.php b/tests/TestCase/Controller/Traits/ProfileTraitTest.php
index 8ac352971..e4a2efdf0 100644
--- a/tests/TestCase/Controller/Traits/ProfileTraitTest.php
+++ b/tests/TestCase/Controller/Traits/ProfileTraitTest.php
@@ -46,7 +46,7 @@ public function setUp()
*/
public function testProfileGetNotLoggedInUserNotFound()
{
- $userId = 'not-found';
+ $userId = '00000000-0000-0000-0000-000000000000'; //not found
$this->_mockRequestGet();
$this->_mockAuth();
$this->_mockFlash();
@@ -63,7 +63,7 @@ public function testProfileGetNotLoggedInUserNotFound()
*/
public function testProfileGetLoggedInUserNotFound()
{
- $userId = 'not-found';
+ $userId = '00000000-0000-0000-0000-000000000000'; //not found
$this->_mockRequestGet();
$this->_mockAuthLoggedIn();
$this->_mockFlash();
diff --git a/tests/TestCase/Controller/Traits/SimpleCrudTraitTest.php b/tests/TestCase/Controller/Traits/SimpleCrudTraitTest.php
index c155947d4..570d2d50f 100644
--- a/tests/TestCase/Controller/Traits/SimpleCrudTraitTest.php
+++ b/tests/TestCase/Controller/Traits/SimpleCrudTraitTest.php
@@ -101,7 +101,7 @@ public function testView()
*/
public function testViewNotFound()
{
- $this->Trait->view('not-found');
+ $this->Trait->view('00000000-0000-0000-0000-000000000000');
}
/**
@@ -274,8 +274,6 @@ public function testDeleteNotFound()
->with(['post', 'delete'])
->will($this->returnValue(true));
- $this->Trait->delete('not-found');
-
- $this->assertNotEmpty($this->table->get('00000000-0000-0000-0000-000000000001'));
+ $this->Trait->delete('00000000-0000-0000-0000-000000000000');
}
}
From f719c84dc0fecbaf30ab10d2bf44a31f8068a3ca Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Tue, 22 Sep 2015 01:17:17 +0000
Subject: [PATCH 0175/1397] fix docblock
---
src/Auth/RememberMeAuthenticate.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/Auth/RememberMeAuthenticate.php b/src/Auth/RememberMeAuthenticate.php
index f92cf4582..3ae70dff7 100644
--- a/src/Auth/RememberMeAuthenticate.php
+++ b/src/Auth/RememberMeAuthenticate.php
@@ -28,7 +28,6 @@ class RememberMeAuthenticate extends BaseAuthenticate
*
* @param Request $request Cake request object.
* @param Response $response Cake response object.
- * @param array $cookie Array with value, key cookie.
* @return mixed
*/
public function authenticate(Request $request, Response $response)
From 51a3b354b36fec5a685c2e07033df79b8e0c359a Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Tue, 22 Sep 2015 01:21:54 +0000
Subject: [PATCH 0176/1397] fix phpcs
---
src/Model/Behavior/RegisterBehavior.php | 13 +++++++------
src/Model/Entity/User.php | 2 +-
src/View/Helper/UserHelper.php | 2 +-
3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/Model/Behavior/RegisterBehavior.php b/src/Model/Behavior/RegisterBehavior.php
index d5ff87812..efced02a6 100644
--- a/src/Model/Behavior/RegisterBehavior.php
+++ b/src/Model/Behavior/RegisterBehavior.php
@@ -11,6 +11,11 @@
namespace CakeDC\Users\Model\Behavior;
+use CakeDC\Users\Exception\TokenExpiredException;
+use CakeDC\Users\Exception\UserAlreadyActiveException;
+use CakeDC\Users\Exception\UserNotFoundException;
+use CakeDC\Users\Model\Behavior\Behavior;
+use CakeDC\Users\Model\Entity\User;
use Cake\Core\Configure;
use Cake\Datasource\EntityInterface;
use Cake\Event\Event;
@@ -18,11 +23,6 @@
use Cake\Validation\Validator;
use DateTime;
use InvalidArgumentException;
-use CakeDC\Users\Exception\TokenExpiredException;
-use CakeDC\Users\Exception\UserAlreadyActiveException;
-use CakeDC\Users\Exception\UserNotFoundException;
-use CakeDC\Users\Model\Behavior\Behavior;
-use CakeDC\Users\Model\Entity\User;
/**
@@ -125,7 +125,8 @@ public function activateUser(EntityInterface $user)
* @param string $name name
* @return Validator
*/
- public function buildValidator(Event $event, Validator $validator, $name){
+ public function buildValidator(Event $event, Validator $validator, $name)
+ {
if ($name === 'default') {
return $this->_emailValidator($validator, $this->validateEmail);
}
diff --git a/src/Model/Entity/User.php b/src/Model/Entity/User.php
index 37d36afe4..f33b5e51d 100644
--- a/src/Model/Entity/User.php
+++ b/src/Model/Entity/User.php
@@ -81,7 +81,7 @@ protected function _setTos($tos)
* Hash a password using the configured password hasher,
* use DefaultPasswordHasher if no one was configured
*
- * @param $password
+ * @param string $password password to be hashed
* @return mixed
*/
public function hashPassword($password)
diff --git a/src/View/Helper/UserHelper.php b/src/View/Helper/UserHelper.php
index aa713ab4c..f1abb3417 100644
--- a/src/View/Helper/UserHelper.php
+++ b/src/View/Helper/UserHelper.php
@@ -11,11 +11,11 @@
namespace CakeDC\Users\View\Helper;
+use CakeDC\Users\Controller\Component\UsersAuthComponent;
use Cake\Core\Configure;
use Cake\Event\Event;
use Cake\Utility\Hash;
use Cake\View\Helper;
-use CakeDC\Users\Controller\Component\UsersAuthComponent;
/**
* User helper
From d62bf8caf2b4a56d1e7615e4bc93d059b051174a Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Tue, 22 Sep 2015 01:26:05 +0000
Subject: [PATCH 0177/1397] fix phpcs
---
src/Model/Behavior/PasswordBehavior.php | 10 +++++-----
src/Model/Behavior/SocialAccountBehavior.php | 10 +++++-----
src/Model/Behavior/SocialBehavior.php | 1 -
3 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/Model/Behavior/PasswordBehavior.php b/src/Model/Behavior/PasswordBehavior.php
index de3794c76..76b4a2d42 100644
--- a/src/Model/Behavior/PasswordBehavior.php
+++ b/src/Model/Behavior/PasswordBehavior.php
@@ -11,14 +11,14 @@
namespace CakeDC\Users\Model\Behavior;
-use Cake\Datasource\EntityInterface;
-use Cake\Network\Email\Email;
-use Cake\Utility\Hash;
-use InvalidArgumentException;
use CakeDC\Users\Exception\UserAlreadyActiveException;
use CakeDC\Users\Exception\UserNotFoundException;
use CakeDC\Users\Exception\WrongPasswordException;
use CakeDC\Users\Model\Behavior\Behavior;
+use Cake\Datasource\EntityInterface;
+use Cake\Network\Email\Email;
+use Cake\Utility\Hash;
+use InvalidArgumentException;
/**
* Covers the password management features
@@ -89,7 +89,7 @@ protected function _getUser($reference)
* instance
* @return array email send result
*/
- public function sendResetPasswordEmail(EntityInterface $user, Email $email = null, $template)
+ public function sendResetPasswordEmail(EntityInterface $user, Email $email = null, $template = 'CakeDC/Users.reset_password')
{
$firstName = isset($user['first_name'])? $user['first_name'] . ', ' : '';
$subject = __d('Users', '{0}Your reset password link', $firstName);
diff --git a/src/Model/Behavior/SocialAccountBehavior.php b/src/Model/Behavior/SocialAccountBehavior.php
index 046c70749..e9cf6d3eb 100644
--- a/src/Model/Behavior/SocialAccountBehavior.php
+++ b/src/Model/Behavior/SocialAccountBehavior.php
@@ -12,6 +12,11 @@
namespace CakeDC\Users\Model\Behavior;
use ArrayObject;
+use CakeDC\Users\Exception\AccountAlreadyActiveException;
+use CakeDC\Users\Exception\AccountNotActiveException;
+use CakeDC\Users\Exception\MissingEmailException;
+use CakeDC\Users\Model\Behavior\Behavior;
+use CakeDC\Users\Model\Entity\User;
use Cake\Core\Configure;
use Cake\Datasource\EntityInterface;
use Cake\Datasource\Exception\RecordNotFoundException;
@@ -19,11 +24,6 @@
use Cake\Network\Email\Email;
use Cake\ORM\Entity;
use InvalidArgumentException;
-use CakeDC\Users\Exception\AccountAlreadyActiveException;
-use CakeDC\Users\Exception\AccountNotActiveException;
-use CakeDC\Users\Exception\MissingEmailException;
-use CakeDC\Users\Model\Behavior\Behavior;
-use CakeDC\Users\Model\Entity\User;
/**
* Covers social account features
diff --git a/src/Model/Behavior/SocialBehavior.php b/src/Model/Behavior/SocialBehavior.php
index fa43fe77b..0a062f88e 100644
--- a/src/Model/Behavior/SocialBehavior.php
+++ b/src/Model/Behavior/SocialBehavior.php
@@ -155,7 +155,6 @@ protected function _populateUser($data, $existingUser, $useEmail, $validateEmail
$userData['username'] = strtolower($firstName . $lastName);
$userData['username'] = preg_replace('/[^A-Za-z0-9]/i', '', Hash::get($userData, 'username'));
}
-
}
$userData['username'] = $this->generateUniqueUsername(Hash::get($userData, 'username'));
if ($useEmail) {
From 73dedd2a093a528c1f97e878c4d853b5c718c385 Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Tue, 22 Sep 2015 01:37:04 +0000
Subject: [PATCH 0178/1397] fix phpcs
---
src/Controller/Component/UsersAuthComponent.php | 2 +-
src/Controller/SocialAccountsController.php | 4 ++--
src/Controller/Traits/LoginTrait.php | 4 ++--
src/Controller/Traits/PasswordManagementTrait.php | 4 ++--
src/Controller/Traits/ProfileTrait.php | 2 +-
src/Controller/Traits/RegisterTrait.php | 2 +-
src/Controller/Traits/SimpleCrudTrait.php | 3 ++-
src/Controller/Traits/SocialTrait.php | 2 +-
src/Controller/Traits/UserValidationTrait.php | 6 +++---
src/Controller/UsersController.php | 7 ++++---
src/Model/Behavior/SocialBehavior.php | 11 +++++++----
src/Model/Table/SocialAccountsTable.php | 5 ++---
src/Model/Table/UsersTable.php | 4 ++--
13 files changed, 30 insertions(+), 26 deletions(-)
diff --git a/src/Controller/Component/UsersAuthComponent.php b/src/Controller/Component/UsersAuthComponent.php
index cf5bd907e..c75ed3d51 100644
--- a/src/Controller/Component/UsersAuthComponent.php
+++ b/src/Controller/Component/UsersAuthComponent.php
@@ -11,13 +11,13 @@
namespace CakeDC\Users\Controller\Component;
+use CakeDC\Users\Exception\BadConfigurationException;
use Cake\Controller\Component;
use Cake\Core\Configure;
use Cake\Event\Event;
use Cake\Network\Request;
use Cake\Routing\Router;
use Cake\Utility\Hash;
-use CakeDC\Users\Exception\BadConfigurationException;
class UsersAuthComponent extends Component
{
diff --git a/src/Controller/SocialAccountsController.php b/src/Controller/SocialAccountsController.php
index 5a6b0207c..5606f204b 100644
--- a/src/Controller/SocialAccountsController.php
+++ b/src/Controller/SocialAccountsController.php
@@ -11,11 +11,11 @@
namespace CakeDC\Users\Controller;
-use Cake\Datasource\Exception\RecordNotFoundException;
-use Cake\Network\Response;
use CakeDC\Users\Controller\AppController;
use CakeDC\Users\Exception\AccountAlreadyActiveException;
use CakeDC\Users\Model\Table\SocialAccountsTable;
+use Cake\Datasource\Exception\RecordNotFoundException;
+use Cake\Network\Response;
/**
* SocialAccounts Controller
diff --git a/src/Controller/Traits/LoginTrait.php b/src/Controller/Traits/LoginTrait.php
index 88e86980e..afde464af 100644
--- a/src/Controller/Traits/LoginTrait.php
+++ b/src/Controller/Traits/LoginTrait.php
@@ -11,11 +11,11 @@
namespace CakeDC\Users\Controller\Traits;
-use Cake\Core\Configure;
-use Cake\Utility\Hash;
use CakeDC\Users\Controller\Component\UsersAuthComponent;
use CakeDC\Users\Exception\AccountNotActiveException;
use CakeDC\Users\Exception\MissingEmailException;
+use Cake\Core\Configure;
+use Cake\Utility\Hash;
/**
* Covers the login, logout and social login
diff --git a/src/Controller/Traits/PasswordManagementTrait.php b/src/Controller/Traits/PasswordManagementTrait.php
index b91f3abb8..ed6008da7 100644
--- a/src/Controller/Traits/PasswordManagementTrait.php
+++ b/src/Controller/Traits/PasswordManagementTrait.php
@@ -11,10 +11,10 @@
namespace CakeDC\Users\Controller\Traits;
-use Cake\Core\Configure;
-use Exception;
use CakeDC\Users\Exception\UserNotFoundException;
use CakeDC\Users\Exception\WrongPasswordException;
+use Cake\Core\Configure;
+use Exception;
/**
* Covers the password management: reset, change
diff --git a/src/Controller/Traits/ProfileTrait.php b/src/Controller/Traits/ProfileTrait.php
index 72f6562e7..a9edbdd47 100644
--- a/src/Controller/Traits/ProfileTrait.php
+++ b/src/Controller/Traits/ProfileTrait.php
@@ -36,7 +36,7 @@ public function profile($id = null)
}
try {
$appContain = (array)Configure::read('Auth.authenticate.' . \Cake\Controller\Component\AuthComponent::ALL . '.contain');
- $socialContain = Configure::read('Users.Social.login') ? ['SocialAccounts']: [];
+ $socialContain = Configure::read('Users.Social.login') ? ['SocialAccounts']: [];
$user = $this->getUsersTable()->get($id, [
'contain' => array_merge((array)$appContain, (array)$socialContain)
]);
diff --git a/src/Controller/Traits/RegisterTrait.php b/src/Controller/Traits/RegisterTrait.php
index ed033a600..b572b6811 100644
--- a/src/Controller/Traits/RegisterTrait.php
+++ b/src/Controller/Traits/RegisterTrait.php
@@ -11,12 +11,12 @@
namespace CakeDC\Users\Controller\Traits;
+use CakeDC\Users\Controller\Component\UsersAuthComponent;
use Cake\Core\Configure;
use Cake\Datasource\EntityInterface;
use Cake\Network\Exception\NotFoundException;
use Cake\Network\Response;
use InvalidArgumentException;
-use CakeDC\Users\Controller\Component\UsersAuthComponent;
/**
* Covers registration features and email token validation
diff --git a/src/Controller/Traits/SimpleCrudTrait.php b/src/Controller/Traits/SimpleCrudTrait.php
index 71280f225..34b0b7634 100644
--- a/src/Controller/Traits/SimpleCrudTrait.php
+++ b/src/Controller/Traits/SimpleCrudTrait.php
@@ -12,6 +12,7 @@
namespace CakeDC\Users\Controller\Traits;
use Cake\Network\Exception\NotFoundException;
+use Cake\Network\Response;
use Cake\ORM\TableRegistry;
use Cake\Utility\Inflector;
@@ -112,7 +113,7 @@ public function edit($id = null)
* Delete method
*
* @param string|null $id User id.
- * @return void Redirects to index.
+ * @return Response Redirects to index.
* @throws NotFoundException When record not found.
*/
public function delete($id = null)
diff --git a/src/Controller/Traits/SocialTrait.php b/src/Controller/Traits/SocialTrait.php
index 2a5f9bf26..ba788c7d8 100644
--- a/src/Controller/Traits/SocialTrait.php
+++ b/src/Controller/Traits/SocialTrait.php
@@ -11,10 +11,10 @@
namespace CakeDC\Users\Controller\Traits;
+use CakeDC\Users\Auth\Factory\OpauthFactory;
use Cake\Core\Configure;
use Cake\Network\Exception\NotFoundException;
use Cake\Routing\Router;
-use CakeDC\Users\Auth\Factory\OpauthFactory;
/**
* Covers registration features and email token validation
diff --git a/src/Controller/Traits/UserValidationTrait.php b/src/Controller/Traits/UserValidationTrait.php
index 23d0a2134..8846c72a6 100644
--- a/src/Controller/Traits/UserValidationTrait.php
+++ b/src/Controller/Traits/UserValidationTrait.php
@@ -11,13 +11,13 @@
namespace CakeDC\Users\Controller\Traits;
+use CakeDC\Users\Exception\TokenExpiredException;
+use CakeDC\Users\Exception\UserAlreadyActiveException;
+use CakeDC\Users\Exception\UserNotFoundException;
use Cake\Core\Configure;
use Cake\Network\Response;
use Exception;
use InvalidArgumentException;
-use CakeDC\Users\Exception\TokenExpiredException;
-use CakeDC\Users\Exception\UserAlreadyActiveException;
-use CakeDC\Users\Exception\UserNotFoundException;
/**
* Covers the user validation
diff --git a/src/Controller/UsersController.php b/src/Controller/UsersController.php
index 8467444f1..a0337b31a 100644
--- a/src/Controller/UsersController.php
+++ b/src/Controller/UsersController.php
@@ -19,6 +19,7 @@
use CakeDC\Users\Controller\Traits\SocialTrait;
use CakeDC\Users\Model\Table\UsersTable;
use Cake\Core\Configure;
+use Cake\ORM\Table;
/**
* Users Controller
@@ -35,9 +36,9 @@ class UsersController extends AppController
/**
* Override loadModel to load specific users table
- * @param null $modelClass
- * @param string $type
- * @return object
+ * @param string $modelClass model class
+ * @param string $type type
+ * @return Table
*/
public function loadModel($modelClass = null, $type = 'Table')
{
diff --git a/src/Model/Behavior/SocialBehavior.php b/src/Model/Behavior/SocialBehavior.php
index 0a062f88e..44290ad3b 100644
--- a/src/Model/Behavior/SocialBehavior.php
+++ b/src/Model/Behavior/SocialBehavior.php
@@ -11,15 +11,15 @@
namespace CakeDC\Users\Model\Behavior;
-use Cake\Datasource\EntityInterface;
-use Cake\Utility\Hash;
-use DateTime;
-use InvalidArgumentException;
use CakeDC\Users\Exception\AccountNotActiveException;
use CakeDC\Users\Exception\MissingEmailException;
use CakeDC\Users\Model\Behavior\Behavior;
use CakeDC\Users\Model\Table\SocialAccountsTable;
use CakeDC\Users\Traits\RandomStringTrait;
+use Cake\Datasource\EntityInterface;
+use Cake\Utility\Hash;
+use DateTime;
+use InvalidArgumentException;
/**
* Covers social features
@@ -185,6 +185,9 @@ protected function _populateUser($data, $existingUser, $useEmail, $validateEmail
/**
* Create a link for facebook profile
+ *
+ * @param array $raw raw data array returned by Facebook
+ * @return string url to facebook profile
*/
protected function _getFacebookLink($raw = [])
{
diff --git a/src/Model/Table/SocialAccountsTable.php b/src/Model/Table/SocialAccountsTable.php
index 0531617fd..50f953e0f 100644
--- a/src/Model/Table/SocialAccountsTable.php
+++ b/src/Model/Table/SocialAccountsTable.php
@@ -11,8 +11,9 @@
namespace CakeDC\Users\Model\Table;
-use App\Model\Entity\Account;
use ArrayObject;
+use CakeDC\Users\Exception\AccountAlreadyActiveException;
+use CakeDC\Users\Model\Entity\User;
use Cake\Core\Configure;
use Cake\Datasource\EntityInterface;
use Cake\Datasource\Exception\RecordNotFoundException;
@@ -22,8 +23,6 @@
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
-use CakeDC\Users\Exception\AccountAlreadyActiveException;
-use CakeDC\Users\Model\Entity\User;
/**
* SocialAccounts Model
diff --git a/src/Model/Table/UsersTable.php b/src/Model/Table/UsersTable.php
index cd62306a6..1c33e92f6 100644
--- a/src/Model/Table/UsersTable.php
+++ b/src/Model/Table/UsersTable.php
@@ -11,14 +11,14 @@
namespace CakeDC\Users\Model\Table;
+use CakeDC\Users\Exception\WrongPasswordException;
+use CakeDC\Users\Model\Entity\User;
use Cake\Datasource\EntityInterface;
use Cake\Network\Email\Email;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Utility\Hash;
use Cake\Validation\Validator;
-use CakeDC\Users\Exception\WrongPasswordException;
-use CakeDC\Users\Model\Entity\User;
/**
* Users Model
From eb87cdb75788e5f3fd5e9be378242df1ab798574 Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Tue, 22 Sep 2015 01:41:30 +0000
Subject: [PATCH 0179/1397] fix phpcs
---
src/Shell/UsersShell.php | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/src/Shell/UsersShell.php b/src/Shell/UsersShell.php
index f24952bbc..630e06ae1 100644
--- a/src/Shell/UsersShell.php
+++ b/src/Shell/UsersShell.php
@@ -11,11 +11,11 @@
namespace CakeDC\Users\Shell;
+use CakeDC\Users\Model\Entity\User;
use Cake\Auth\DefaultPasswordHasher;
use Cake\Console\Shell;
use Cake\Core\Configure;
use Cake\Utility\Hash;
-use CakeDC\Users\Model\Entity\User;
/**
* Shell with utilities for the Users Plugin
@@ -64,8 +64,7 @@ public function getOptionParser()
'username' => ['short' => 'u', 'help' => 'The username for the new user'],
'password' => ['short' => 'p', 'help' => 'The password for the new user'],
'email' => ['short' => 'e', 'help' => 'The email for the new user']
- ])
- ;
+ ]);
return $parser;
}
@@ -226,7 +225,6 @@ public function activateUser()
{
$user = $this->_changeUserActive(true);
$this->out(__d('Users', 'User was activated: {0}', $user->username));
-
}
/**
@@ -272,7 +270,8 @@ public function passwordEmail()
/**
* Change user active field
*
- * @param $active
+ * @param $active active value
+ * @return bool
*/
protected function _changeUserActive($active)
{
@@ -289,12 +288,12 @@ protected function _changeUserActive($active)
/**
* Update user by username
*
- * @param $username
- * @param $data
+ * @param string $username username
+ * @param array $data data
+ * @return bool
*/
protected function _updateUser($username, $data)
{
- /** @var \Users\Model\Entity\User */
$user = $this->Users->find()->where(['Users.username' => $username])->first();
if (empty($user)) {
$this->error(__d('Users', 'The user was not found.'));
@@ -333,7 +332,7 @@ public function deleteUser()
/**
* Generates a random password.
*
- * @return void
+ * @return string
*/
protected function _generateRandomPassword()
{
@@ -343,7 +342,7 @@ protected function _generateRandomPassword()
/**
* Generates a random username based on a list of preexisting ones.
*
- * @return void
+ * @return string
*/
protected function _generateRandomUsername()
{
@@ -353,8 +352,8 @@ protected function _generateRandomUsername()
/**
* Hash a password
*
- * @param password
- * @return void
+ * @param string $password password
+ * @return string
*/
protected function _generatedHashedPassword($password)
{
From 0205ce20f7412291e08583fc8c44249608c7906e Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Tue, 22 Sep 2015 01:46:39 +0000
Subject: [PATCH 0180/1397] fix phpcs
---
tests/TestCase/Auth/RememberMeAuthenticateTest.php | 4 ++--
tests/TestCase/Auth/SimpleRbacAuthorizeTest.php | 2 +-
tests/TestCase/Auth/SuperuserAuthorizeTest.php | 2 +-
.../Controller/Component/RememberMeComponentTest.php | 2 +-
.../Controller/Component/UsersAuthComponentTest.php | 6 +++---
tests/TestCase/Controller/Traits/LoginTraitTest.php | 8 ++++----
tests/TestCase/Controller/Traits/ProfileTraitTest.php | 2 +-
tests/TestCase/Controller/Traits/RegisterTraitTest.php | 2 +-
tests/TestCase/Controller/Traits/SimpleCrudTraitTest.php | 2 +-
.../Controller/Traits/UserValidationTraitTest.php | 2 +-
tests/TestCase/Model/Behavior/PasswordBehaviorTest.php | 4 ++--
.../TestCase/Model/Behavior/SocialAccountBehaviorTest.php | 2 +-
tests/TestCase/Model/Entity/UserTest.php | 2 +-
tests/TestCase/Model/Table/SocialAccountsTableTest.php | 4 ++--
tests/TestCase/Model/Table/UsersTableTest.php | 8 ++++----
tests/TestCase/View/Helper/UserHelperTest.php | 2 +-
16 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/tests/TestCase/Auth/RememberMeAuthenticateTest.php b/tests/TestCase/Auth/RememberMeAuthenticateTest.php
index b0d60f4bb..960a573c2 100644
--- a/tests/TestCase/Auth/RememberMeAuthenticateTest.php
+++ b/tests/TestCase/Auth/RememberMeAuthenticateTest.php
@@ -11,14 +11,14 @@
namespace CakeDC\Users\Test\TestCase\Auth;
+use CakeDC\Users\Auth\RememberMeAuthenticate;
+use CakeDC\Users\Auth\SuperuserAuthorize;
use Cake\Controller\ComponentRegistry;
use Cake\Controller\Controller;
use Cake\Event\EventManager;
use Cake\Network\Request;
use Cake\Network\Response;
use Cake\TestSuite\TestCase;
-use CakeDC\Users\Auth\RememberMeAuthenticate;
-use CakeDC\Users\Auth\SuperuserAuthorize;
class RememberMeAuthenticateTest extends TestCase
{
diff --git a/tests/TestCase/Auth/SimpleRbacAuthorizeTest.php b/tests/TestCase/Auth/SimpleRbacAuthorizeTest.php
index 3f758bd1f..9ab9f8ab5 100644
--- a/tests/TestCase/Auth/SimpleRbacAuthorizeTest.php
+++ b/tests/TestCase/Auth/SimpleRbacAuthorizeTest.php
@@ -11,6 +11,7 @@
namespace CakeDC\Users\Test\TestCase\Auth;
+use CakeDC\Users\Auth\SimpleRbacAuthorize;
use Cake\Controller\ComponentRegistry;
use Cake\Controller\Controller;
use Cake\Event\EventManager;
@@ -19,7 +20,6 @@
use Cake\TestSuite\TestCase;
use Cake\Utility\Hash;
use ReflectionClass;
-use CakeDC\Users\Auth\SimpleRbacAuthorize;
class SimpleRbacAuthorizeTest extends TestCase
{
diff --git a/tests/TestCase/Auth/SuperuserAuthorizeTest.php b/tests/TestCase/Auth/SuperuserAuthorizeTest.php
index 153ac9158..bde73f341 100644
--- a/tests/TestCase/Auth/SuperuserAuthorizeTest.php
+++ b/tests/TestCase/Auth/SuperuserAuthorizeTest.php
@@ -11,13 +11,13 @@
namespace CakeDC\Users\Test\TestCase\Auth;
+use CakeDC\Users\Auth\SuperuserAuthorize;
use Cake\Controller\ComponentRegistry;
use Cake\Controller\Controller;
use Cake\Event\EventManager;
use Cake\Network\Request;
use Cake\Network\Response;
use Cake\TestSuite\TestCase;
-use CakeDC\Users\Auth\SuperuserAuthorize;
class SuperuserAuthorizeTest extends TestCase
{
diff --git a/tests/TestCase/Controller/Component/RememberMeComponentTest.php b/tests/TestCase/Controller/Component/RememberMeComponentTest.php
index 6f453f6fa..701bdf587 100644
--- a/tests/TestCase/Controller/Component/RememberMeComponentTest.php
+++ b/tests/TestCase/Controller/Component/RememberMeComponentTest.php
@@ -11,6 +11,7 @@
namespace CakeDC\Users\Test\TestCase\Controller\Component;
+use CakeDC\Users\Controller\Component\RememberMeComponent;
use Cake\Controller\ComponentRegistry;
use Cake\Controller\Component\AuthComponent;
use Cake\Controller\Component\CookieComponent;
@@ -22,7 +23,6 @@
use Cake\TestSuite\TestCase;
use Cake\Utility\Security;
use InvalidArgumentException;
-use CakeDC\Users\Controller\Component\RememberMeComponent;
/**
* Users\Controller\Component\RememberMeComponent Test Case
diff --git a/tests/TestCase/Controller/Component/UsersAuthComponentTest.php b/tests/TestCase/Controller/Component/UsersAuthComponentTest.php
index c68968e71..2c45e2f9c 100644
--- a/tests/TestCase/Controller/Component/UsersAuthComponentTest.php
+++ b/tests/TestCase/Controller/Component/UsersAuthComponentTest.php
@@ -11,6 +11,9 @@
namespace CakeDC\Users\Test\TestCase\Controller\Component;
+use CakeDC\Users\Controller\Component\UsersAuthComponent;
+use CakeDC\Users\Exception\MissingEmailException;
+use CakeDC\Users\Exception\UserNotFoundException;
use Cake\Controller\Controller;
use Cake\Core\Configure;
use Cake\Core\Plugin;
@@ -22,9 +25,6 @@
use Cake\Routing\Router;
use Cake\TestSuite\TestCase;
use Cake\Utility\Security;
-use CakeDC\Users\Controller\Component\UsersAuthComponent;
-use CakeDC\Users\Exception\MissingEmailException;
-use CakeDC\Users\Exception\UserNotFoundException;
/**
* Users\Controller\Component\UsersAuthComponent Test Case
diff --git a/tests/TestCase/Controller/Traits/LoginTraitTest.php b/tests/TestCase/Controller/Traits/LoginTraitTest.php
index 73c7b7645..88bac68f5 100644
--- a/tests/TestCase/Controller/Traits/LoginTraitTest.php
+++ b/tests/TestCase/Controller/Traits/LoginTraitTest.php
@@ -11,16 +11,16 @@
namespace CakeDC\Users\Test\TestCase\Controller\Traits;
+use CakeDC\Users\Controller\Component\UsersAuthComponent;
+use CakeDC\Users\Controller\Traits\LoginTrait;
+use CakeDC\Users\Exception\AccountNotActiveException;
+use CakeDC\Users\Exception\MissingEmailException;
use Cake\Controller\Controller;
use Cake\Core\Configure;
use Cake\Event\Event;
use Cake\Network\Request;
use Cake\TestSuite\TestCase;
use Opauth\Opauth\Response;
-use CakeDC\Users\Controller\Component\UsersAuthComponent;
-use CakeDC\Users\Controller\Traits\LoginTrait;
-use CakeDC\Users\Exception\AccountNotActiveException;
-use CakeDC\Users\Exception\MissingEmailException;
class LoginTraitTest extends TestCase
{
diff --git a/tests/TestCase/Controller/Traits/ProfileTraitTest.php b/tests/TestCase/Controller/Traits/ProfileTraitTest.php
index e4a2efdf0..c88a45cb1 100644
--- a/tests/TestCase/Controller/Traits/ProfileTraitTest.php
+++ b/tests/TestCase/Controller/Traits/ProfileTraitTest.php
@@ -11,9 +11,9 @@
namespace CakeDC\Users\Test\TestCase\Controller\Traits;
-use Cake\ORM\TableRegistry;
use CakeDC\Users\Controller\Traits\ProfileTrait;
use CakeDC\Users\Test\TestCase\Controller\Traits\BaseTraitTest;
+use Cake\ORM\TableRegistry;
class ProfileTraitTest extends BaseTraitTest
{
diff --git a/tests/TestCase/Controller/Traits/RegisterTraitTest.php b/tests/TestCase/Controller/Traits/RegisterTraitTest.php
index fb4022b50..7d737f45b 100644
--- a/tests/TestCase/Controller/Traits/RegisterTraitTest.php
+++ b/tests/TestCase/Controller/Traits/RegisterTraitTest.php
@@ -11,11 +11,11 @@
namespace CakeDC\Users\Test\TestCase\Controller\Traits;
+use CakeDC\Users\Test\TestCase\Controller\Traits\BaseTraitTest;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Network\Email\Email;
use Cake\ORM\TableRegistry;
-use CakeDC\Users\Test\TestCase\Controller\Traits\BaseTraitTest;
class RegisterTraitTest extends BaseTraitTest
{
diff --git a/tests/TestCase/Controller/Traits/SimpleCrudTraitTest.php b/tests/TestCase/Controller/Traits/SimpleCrudTraitTest.php
index 570d2d50f..2e807ebda 100644
--- a/tests/TestCase/Controller/Traits/SimpleCrudTraitTest.php
+++ b/tests/TestCase/Controller/Traits/SimpleCrudTraitTest.php
@@ -11,8 +11,8 @@
namespace CakeDC\Users\Test\TestCase\Controller\Traits;
-use Cake\Network\Request;
use CakeDC\Users\Test\TestCase\Controller\Traits\BaseTraitTest;
+use Cake\Network\Request;
class SimpleCrudTraitTest extends BaseTraitTest
{
diff --git a/tests/TestCase/Controller/Traits/UserValidationTraitTest.php b/tests/TestCase/Controller/Traits/UserValidationTraitTest.php
index b15197a0e..e84d208bb 100644
--- a/tests/TestCase/Controller/Traits/UserValidationTraitTest.php
+++ b/tests/TestCase/Controller/Traits/UserValidationTraitTest.php
@@ -11,8 +11,8 @@
namespace CakeDC\Users\Test\TestCase\Controller\Traits;
-use Cake\Network\Request;
use CakeDC\Users\Test\TestCase\Controller\Traits\BaseTraitTest;
+use Cake\Network\Request;
class UserValidationTraitTest extends BaseTraitTest
{
diff --git a/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php b/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php
index 6960a849b..3ae02dfb2 100644
--- a/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php
+++ b/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php
@@ -11,13 +11,13 @@
namespace CakeDC\Users\Test\TestCase\Model\Behavior;
+use CakeDC\Users\Exception\UserAlreadyActiveException;
+use CakeDC\Users\Model\Table\UsersTable;
use Cake\Network\Email\Email;
use Cake\ORM\TableRegistry;
use Cake\Routing\Router;
use Cake\TestSuite\TestCase;
use InvalidArgumentException;
-use CakeDC\Users\Exception\UserAlreadyActiveException;
-use CakeDC\Users\Model\Table\UsersTable;
/**
* Test Case
diff --git a/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php b/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php
index f6436bc7c..d341d6927 100644
--- a/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php
+++ b/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php
@@ -11,13 +11,13 @@
namespace CakeDC\Users\Test\TestCase\Model\Behavior;
+use CakeDC\Users\Model\Table\SocialAccountsTable;
use Cake\Event\Event;
use Cake\Network\Email\Email;
use Cake\ORM\TableRegistry;
use Cake\Routing\Router;
use Cake\TestSuite\TestCase;
use InvalidArgumentException;
-use CakeDC\Users\Model\Table\SocialAccountsTable;
/**
* Test Case
diff --git a/tests/TestCase/Model/Entity/UserTest.php b/tests/TestCase/Model/Entity/UserTest.php
index 00f4f89c6..2788aa8ad 100644
--- a/tests/TestCase/Model/Entity/UserTest.php
+++ b/tests/TestCase/Model/Entity/UserTest.php
@@ -1,9 +1,9 @@
Date: Tue, 22 Sep 2015 01:51:30 +0000
Subject: [PATCH 0181/1397] fix phpcs
---
src/Model/Behavior/RegisterBehavior.php | 1 -
src/Shell/UsersShell.php | 2 +-
tests/TestCase/Model/Behavior/PasswordBehaviorTest.php | 1 -
tests/TestCase/Shell/UsersShellTest.php | 5 -----
4 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/src/Model/Behavior/RegisterBehavior.php b/src/Model/Behavior/RegisterBehavior.php
index efced02a6..ab95edc72 100644
--- a/src/Model/Behavior/RegisterBehavior.php
+++ b/src/Model/Behavior/RegisterBehavior.php
@@ -24,7 +24,6 @@
use DateTime;
use InvalidArgumentException;
-
/**
* Covers the user registration
*/
diff --git a/src/Shell/UsersShell.php b/src/Shell/UsersShell.php
index 630e06ae1..634b21462 100644
--- a/src/Shell/UsersShell.php
+++ b/src/Shell/UsersShell.php
@@ -270,7 +270,7 @@ public function passwordEmail()
/**
* Change user active field
*
- * @param $active active value
+ * @param bool $active active value
* @return bool
*/
protected function _changeUserActive($active)
diff --git a/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php b/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php
index 3ae02dfb2..85defd0f8 100644
--- a/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php
+++ b/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php
@@ -209,5 +209,4 @@ public function testSendResetPasswordEmail()
Router::fullBaseUrl($this->fullBaseBackup);
Email::dropTransport('test');
}
-
}
diff --git a/tests/TestCase/Shell/UsersShellTest.php b/tests/TestCase/Shell/UsersShellTest.php
index 89176be30..35592090e 100644
--- a/tests/TestCase/Shell/UsersShellTest.php
+++ b/tests/TestCase/Shell/UsersShellTest.php
@@ -111,7 +111,6 @@ public function testAddUser()
//TODO: Add assertions with 'out'
$this->Shell->runCommand(['addUser', '--username=' . $user['username'], '--password=' . $user['password'], '--email=' . $user['email']]);
-
}
/**
@@ -160,7 +159,6 @@ public function testAddUserWithNoParams()
//TODO: Add assertions with 'out'
$this->Shell->runCommand(['addUser']);
-
}
/**
@@ -203,7 +201,6 @@ public function testAddSuperuser()
->will($this->returnValue($userSaved));
$this->Shell->runCommand(['addSuperuser']);
-
}
/**
@@ -222,7 +219,6 @@ public function testResetAllPasswords()
->with(['password' => 'hashedPasssword'], ['id IS NOT NULL']);
$this->Shell->runCommand(['resetAllPasswords', '123']);
-
}
/**
@@ -237,6 +233,5 @@ public function testResetAllPasswordsNoPassingParams()
->with('Please enter a password.');
$this->Shell->runCommand(['resetAllPasswords']);
-
}
}
From 4f668f6a9aabb96f868b1a921a3865539c8466a9 Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Tue, 22 Sep 2015 01:52:11 +0000
Subject: [PATCH 0182/1397] fix phpcs
---
tests/App/Controller/AppController.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/tests/App/Controller/AppController.php b/tests/App/Controller/AppController.php
index 9f88e565a..5899a4e41 100644
--- a/tests/App/Controller/AppController.php
+++ b/tests/App/Controller/AppController.php
@@ -21,5 +21,4 @@ public function initialize()
// $this->loadComponent('CakeDC/Users.UsersAuth');
$this->loadComponent('RequestHandler');
}
-
}
From 49d8a0a6380d276aa0b702e1b5bc1d797d1920c4 Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Tue, 22 Sep 2015 01:56:01 +0000
Subject: [PATCH 0183/1397] fix phpcs
---
.../TestCase/Controller/SocialAccountsControllerTest.php | 2 +-
tests/TestCase/Model/Table/UsersTableTest.php | 8 ++++----
tests/TestCase/Shell/UsersShellTest.php | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/tests/TestCase/Controller/SocialAccountsControllerTest.php b/tests/TestCase/Controller/SocialAccountsControllerTest.php
index 27501e316..7f4c6a714 100644
--- a/tests/TestCase/Controller/SocialAccountsControllerTest.php
+++ b/tests/TestCase/Controller/SocialAccountsControllerTest.php
@@ -12,8 +12,8 @@
namespace CakeDC\Users\Test\TestCase\Controller;
use CakeDC\Users\Controller\SocialAccountsController;
-use CakeDC\Users\Model\Table\SocialAccountsTable;
use CakeDC\Users\Model\Behavior\SocialAccountBehavior;
+use CakeDC\Users\Model\Table\SocialAccountsTable;
use Cake\Core\Configure;
use Cake\Event\EventManager;
use Cake\Network\Email\Email;
diff --git a/tests/TestCase/Model/Table/UsersTableTest.php b/tests/TestCase/Model/Table/UsersTableTest.php
index 51b83d3dc..216bf7c84 100644
--- a/tests/TestCase/Model/Table/UsersTableTest.php
+++ b/tests/TestCase/Model/Table/UsersTableTest.php
@@ -178,7 +178,7 @@ public function testActivateUser()
$this->assertTrue($result->active);
}
- public function _testSocialLogin()
+ public function testSocialLogin()
{
$raw = [
'id' => 'reference-2-1',
@@ -205,7 +205,7 @@ public function _testSocialLogin()
*
* @expectedException CakeDC\Users\Exception\AccountNotActiveException
*/
- public function _testSocialLoginInactiveAccount()
+ public function testSocialLoginInactiveAccount()
{
$raw = [
'id' => 'reference-2-2',
@@ -231,7 +231,7 @@ public function _testSocialLoginInactiveAccount()
*
* @expectedException InvalidArgumentException
*/
- public function _testSocialLoginddCreateNewAccountWithNoCredentials()
+ public function testSocialLoginddCreateNewAccountWithNoCredentials()
{
$raw = [
'id' => 'reference-not-existing',
@@ -254,7 +254,7 @@ public function _testSocialLoginddCreateNewAccountWithNoCredentials()
* Test socialLogin
*
*/
- public function _testSocialLoginCreateNewAccount()
+ public function testSocialLoginCreateNewAccount()
{
$raw = [
'id' => 'no-existing-reference',
diff --git a/tests/TestCase/Shell/UsersShellTest.php b/tests/TestCase/Shell/UsersShellTest.php
index 35592090e..2980a2dce 100644
--- a/tests/TestCase/Shell/UsersShellTest.php
+++ b/tests/TestCase/Shell/UsersShellTest.php
@@ -214,7 +214,7 @@ public function testResetAllPasswords()
->method('_generatedHashedPassword')
->will($this->returnValue('hashedPasssword'));
- $this->Shell->Users->expects($this->once())
+ $this->Shell->Users->expects($this->once())
->method('updateAll')
->with(['password' => 'hashedPasssword'], ['id IS NOT NULL']);
From 1406eb6fa322b147a0f92411cf74313efd1eabaa Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Tue, 22 Sep 2015 02:28:59 +0000
Subject: [PATCH 0184/1397] fix opauth dependency
---
tests/TestCase/Model/Table/UsersTableTest.php | 37 +++++++++++++------
1 file changed, 25 insertions(+), 12 deletions(-)
diff --git a/tests/TestCase/Model/Table/UsersTableTest.php b/tests/TestCase/Model/Table/UsersTableTest.php
index 216bf7c84..e73977cac 100644
--- a/tests/TestCase/Model/Table/UsersTableTest.php
+++ b/tests/TestCase/Model/Table/UsersTableTest.php
@@ -21,7 +21,6 @@
use Cake\Routing\Router;
use Cake\TestSuite\TestCase;
use InvalidArgumentException;
-use Opauth\Opauth\Response;
/**
* Users\Model\Table\UsersTable Test Case
@@ -188,8 +187,11 @@ public function testSocialLogin()
'user_email' => 'user-2@test.com',
'link' => 'link'
];
- $data = new Response(SocialAccountsTable::PROVIDER_FACEBOOK, $raw);
- $data->setData('uid', 'id');
+ $data = new \Cake\Network\Response();
+ $data->provider = SocialAccountsTable::PROVIDER_FACEBOOK;
+ $data->email = 'user-2@test.com';
+ $data->raw = $raw;
+ $data->uid = 'reference-2-1';
$options = [
'use_email' => 1,
'validate_email' => 1,
@@ -214,8 +216,11 @@ public function testSocialLoginInactiveAccount()
'verified' => 1,
'user_email' => 'hello@test.com',
];
- $data = new Response(SocialAccountsTable::PROVIDER_TWITTER, $raw);
- $data->setData('uid', 'id');
+ $data = new \Cake\Network\Response();
+ $data->provider = SocialAccountsTable::PROVIDER_TWITTER;
+ $data->email = 'hello@test.com';
+ $data->raw = $raw;
+ $data->uid = 'reference-2-2';
$options = [
'use_email' => 1,
'validate_email' => 1,
@@ -239,8 +244,11 @@ public function testSocialLoginddCreateNewAccountWithNoCredentials()
'gender' => 'male',
'user_email' => 'user@test.com',
];
- $data = new Response(SocialAccountsTable::PROVIDER_TWITTER, $raw);
- $data->setData('uid', 'id');
+ $data = new \Cake\Network\Response();
+ $data->provider = SocialAccountsTable::PROVIDER_TWITTER;
+ $data->email = 'user@test.com';
+ $data->raw = $raw;
+ $data->uid = 'reference-not-existing';
$options = [
'use_email' => 0,
'validate_email' => 1,
@@ -265,11 +273,16 @@ public function testSocialLoginCreateNewAccount()
'twitter' => 'link'
];
- $data = new Response(SocialAccountsTable::PROVIDER_TWITTER, $raw);
- $data->setData('uid', 'id');
- $data->setData('info.first_name', 'first_name');
- $data->setData('info.last_name', 'last_name');
- $data->setData('info.urls.twitter', 'twitter');
+ $data = new \Cake\Network\Response();
+ $data->provider = SocialAccountsTable::PROVIDER_TWITTER;
+ $data->email = 'user-2@test.com';
+ $data->raw = $raw;
+ $data->uid = 'no-existing-reference';
+ $data->info = [
+ 'first_name' => 'First Name',
+ 'last_name' => 'Last Name',
+ 'urls' => ['twitter' => 'twitter'],
+ ];
$data->email = 'username@test.com';
$data->credentials = [
From e7cb1a36589f3ef346996845efd17ec38daa9f62 Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Tue, 22 Sep 2015 02:30:07 +0000
Subject: [PATCH 0185/1397] fix array cast for Hash::get
---
src/Auth/SocialAuthenticate.php | 2 +-
src/Model/Behavior/SocialBehavior.php | 16 ++++++++--------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/Auth/SocialAuthenticate.php b/src/Auth/SocialAuthenticate.php
index 80de3834d..46bc12e12 100755
--- a/src/Auth/SocialAuthenticate.php
+++ b/src/Auth/SocialAuthenticate.php
@@ -38,7 +38,7 @@ public function authenticate(Request $request, Response $response)
if (empty($data)) {
return false;
}
- $socialMail = Hash::get($data->info, Configure::read('Users.Key.Data.email'));
+ $socialMail = Hash::get((array)$data->info, Configure::read('Users.Key.Data.email'));
if (!empty($socialMail)) {
$data->email = $socialMail;
diff --git a/src/Model/Behavior/SocialBehavior.php b/src/Model/Behavior/SocialBehavior.php
index 44290ad3b..0da027e8c 100644
--- a/src/Model/Behavior/SocialBehavior.php
+++ b/src/Model/Behavior/SocialBehavior.php
@@ -113,17 +113,17 @@ protected function _createSocialUser($data, $options = [])
protected function _populateUser($data, $existingUser, $useEmail, $validateEmail, $tokenExpiration)
{
$accountData['provider'] = $data->provider;
- $accountData['username'] = Hash::get($data->info, 'nickname');
+ $accountData['username'] = Hash::get((array)$data->info, 'nickname');
$accountData['reference'] = $data->uid;
- $accountData['avatar'] = Hash::get($data->info, 'image');
+ $accountData['avatar'] = Hash::get((array)$data->info, 'image');
/* @todo make a pull request to Opauth Facebook Strategy because it does not include link on info array */
if ($data->provider == SocialAccountsTable::PROVIDER_TWITTER) {
- $accountData['link'] = Hash::get($data->info, 'urls.twitter');
+ $accountData['link'] = Hash::get((array)$data->info, 'urls.twitter');
} elseif ($data->provider == SocialAccountsTable::PROVIDER_FACEBOOK) {
$accountData['link'] = $this->_getFacebookLink($data->raw);
}
$accountData['avatar'] = str_replace('square', 'large', $accountData['avatar']);
- $accountData['description'] = Hash::get($data->info, 'description');
+ $accountData['description'] = Hash::get((array)$data->info, 'description');
$accountData['token'] = Hash::get((array)$data->credentials, 'token');
$accountData['token_secret'] = Hash::get((array)$data->credentials, 'secret');
$expires = Hash::get((array)$data->credentials, 'expires');
@@ -132,8 +132,8 @@ protected function _populateUser($data, $existingUser, $useEmail, $validateEmail
$accountData['active'] = true;
if (empty($existingUser)) {
- $firstName = Hash::get($data->info, 'first_name');
- $lastName = Hash::get($data->info, 'last_name');
+ $firstName = Hash::get((array)$data->info, 'first_name');
+ $lastName = Hash::get((array)$data->info, 'last_name');
if (!empty($firstName) && !empty($lastName)) {
$userData['first_name'] = $firstName;
$userData['last_name'] = $lastName;
@@ -143,7 +143,7 @@ protected function _populateUser($data, $existingUser, $useEmail, $validateEmail
array_shift($name);
$userData['last_name'] = implode(' ', $name);
}
- $userData['username'] = Hash::get($data->info, 'nickname');
+ $userData['username'] = Hash::get((array)$data->info, 'nickname');
$username = Hash::get($userData, 'username');
if (empty($username)) {
if (!empty($data->email)) {
@@ -164,7 +164,7 @@ protected function _populateUser($data, $existingUser, $useEmail, $validateEmail
}
}
$userData['password'] = $this->randomString();
- $userData['avatar'] = Hash::get($data->info, 'image');
+ $userData['avatar'] = Hash::get((array)$data->info, 'image');
$userData['validated'] = $data->validated;
$userData['tos_date'] = date("Y-m-d H:i:s");
$userData['gender'] = Hash::get($data->raw, 'gender');
From a3ce4d700070e051d412a6b6a270a7091bd15231 Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Tue, 22 Sep 2015 02:36:18 +0000
Subject: [PATCH 0186/1397] fix social login test
---
tests/TestCase/Model/Table/UsersTableTest.php | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tests/TestCase/Model/Table/UsersTableTest.php b/tests/TestCase/Model/Table/UsersTableTest.php
index e73977cac..8940ab26d 100644
--- a/tests/TestCase/Model/Table/UsersTableTest.php
+++ b/tests/TestCase/Model/Table/UsersTableTest.php
@@ -221,6 +221,9 @@ public function testSocialLoginInactiveAccount()
$data->email = 'hello@test.com';
$data->raw = $raw;
$data->uid = 'reference-2-2';
+ $data->info = [
+ 'first_name' => 'User 2',
+ ];
$options = [
'use_email' => 1,
'validate_email' => 1,
@@ -249,6 +252,9 @@ public function testSocialLoginddCreateNewAccountWithNoCredentials()
$data->email = 'user@test.com';
$data->raw = $raw;
$data->uid = 'reference-not-existing';
+ $data->info = [
+ 'first_name' => 'Not existing user',
+ ];
$options = [
'use_email' => 0,
'validate_email' => 1,
@@ -283,6 +289,7 @@ public function testSocialLoginCreateNewAccount()
'last_name' => 'Last Name',
'urls' => ['twitter' => 'twitter'],
];
+ $data->validated = true;
$data->email = 'username@test.com';
$data->credentials = [
From fc9a7c3e622761a9e5d4bf888ba8e6ce5e10e651 Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Tue, 22 Sep 2015 02:38:55 +0000
Subject: [PATCH 0187/1397] fix social login test
---
tests/TestCase/Model/Table/UsersTableTest.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/TestCase/Model/Table/UsersTableTest.php b/tests/TestCase/Model/Table/UsersTableTest.php
index 8940ab26d..a420943c1 100644
--- a/tests/TestCase/Model/Table/UsersTableTest.php
+++ b/tests/TestCase/Model/Table/UsersTableTest.php
@@ -255,6 +255,7 @@ public function testSocialLoginddCreateNewAccountWithNoCredentials()
$data->info = [
'first_name' => 'Not existing user',
];
+ $data->credentials = [];
$options = [
'use_email' => 0,
'validate_email' => 1,
From fa40b7a2a2e58758bf73799aa1a50b7ef1b88ef0 Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Tue, 22 Sep 2015 02:41:32 +0000
Subject: [PATCH 0188/1397] fix social login test
---
tests/TestCase/Model/Table/UsersTableTest.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/TestCase/Model/Table/UsersTableTest.php b/tests/TestCase/Model/Table/UsersTableTest.php
index a420943c1..a16b11c67 100644
--- a/tests/TestCase/Model/Table/UsersTableTest.php
+++ b/tests/TestCase/Model/Table/UsersTableTest.php
@@ -256,6 +256,7 @@ public function testSocialLoginddCreateNewAccountWithNoCredentials()
'first_name' => 'Not existing user',
];
$data->credentials = [];
+ $data->name = '';
$options = [
'use_email' => 0,
'validate_email' => 1,
From 5e6dc234cafeedb5e96a218545f5ba5a8a88f0ae Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Tue, 22 Sep 2015 02:43:38 +0000
Subject: [PATCH 0189/1397] fix social login test
---
tests/TestCase/Model/Table/UsersTableTest.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/TestCase/Model/Table/UsersTableTest.php b/tests/TestCase/Model/Table/UsersTableTest.php
index a16b11c67..05011fbf7 100644
--- a/tests/TestCase/Model/Table/UsersTableTest.php
+++ b/tests/TestCase/Model/Table/UsersTableTest.php
@@ -239,7 +239,7 @@ public function testSocialLoginInactiveAccount()
*
* @expectedException InvalidArgumentException
*/
- public function testSocialLoginddCreateNewAccountWithNoCredentials()
+ public function testSocialLoginCreateNewAccountWithNoCredentials()
{
$raw = [
'id' => 'reference-not-existing',
@@ -251,6 +251,7 @@ public function testSocialLoginddCreateNewAccountWithNoCredentials()
$data->provider = SocialAccountsTable::PROVIDER_TWITTER;
$data->email = 'user@test.com';
$data->raw = $raw;
+ $data->validated = true;
$data->uid = 'reference-not-existing';
$data->info = [
'first_name' => 'Not existing user',
From 6bb95a3c679f57473ce93dd391a265210441ff70 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Tue, 22 Sep 2015 03:48:47 +0100
Subject: [PATCH 0190/1397] fix travis to ignore phpcs warnings
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 1aea05fd3..b9669e624 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -40,7 +40,7 @@ before_script:
script:
- sh -c "if [ '$DEFAULT' = '1' ]; then phpunit --stderr; fi"
- - sh -c "if [ '$PHPCS' = '1' ]; then ./vendor/bin/phpcs -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests; fi"
+ - sh -c "if [ '$PHPCS' = '1' ]; then ./vendor/bin/phpcs -p -n --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests; fi"
- sh -c "if [ '$COVERALLS' = '1' ]; then phpunit --stderr --coverage-clover build/logs/clover.xml; fi"
- sh -c "if [ '$COVERALLS' = '1' ]; then php vendor/bin/coveralls -c .coveralls.yml -v; fi"
From 684f0c5d131ebce544808668165b49eceff6956f Mon Sep 17 00:00:00 2001
From: David Albrecht
Date: Tue, 22 Sep 2015 12:22:56 +0200
Subject: [PATCH 0191/1397] new German translations
---
Locale/deu/LC_MESSAGES/users.mo | Bin 9265 -> 11745 bytes
Locale/deu/LC_MESSAGES/users.po | 313 ++++++++++++--------------------
2 files changed, 120 insertions(+), 193 deletions(-)
diff --git a/Locale/deu/LC_MESSAGES/users.mo b/Locale/deu/LC_MESSAGES/users.mo
index 67ba5d6917bde5f70d7433d1f3c2472bf888ab8a..295f39e21fb3a5f53ec3501020ffb9f5ad89d545 100644
GIT binary patch
delta 5096
zcmaKtdvIMv8NfFw&?ceprfEY1+m=8IY1)Ps`lL2Z+6I~up~SXe>&d;Fdk?+$oN&&$
zNfRDdv49vT>OnELn!N~PFHG~Qbjd`P9qa*p=_`p%7-Bog|35h;N5oq
zK`0xHLVjwDM-6<|@+g$|Z^9YyJt+H~g!AEtkUOecUe<8Fs;48DJqMl&S6W^OWuuL-
z7H+lN3uV0zMd2Y>50Ah~_+!XVJ;Y-sd=heL^*rQk^?N&h7p~=e^*$XrpqbT8uno?J
z2cdj$1C$$%KsorEcKm%P8$WEvV^B=}YbY0a5z38^L9xJJp}62AY=9rZqI4Q?u=sWZ
zlmqrdIXDZ&R0B{pzRteC11zv$6{1cRQS2HQDG>|*1L$k5}
z20FJgAs>wM5R<+PMe{$y1+apz>R>&T;A@2`*aI~jgIB}X;5xW=u2L7k0LsA+KsoTI
zP|kVUj$fFI{l&CzFoBZlIOM1P%|lE$3vDC@=0kbk0N214JD;}m2jME_uZIiaBTy86
z7Pi1Q;c_?=Kg)O%l;F-4=`_)~4a!Y_1{cHUp?q)xo(Ips9CyHNa3wqnTj8mkA}(AD
zHSB@nvOy?5zaEOK4nuL_SD{$s9w>?w@24X-J!<(Xlnvg5vcWrW89V{S^mS+{2XBCz
zpa*5+hu|9cI2?f|;5l#zbBIOm<#84qgL3m%;YE`F|D+=at{{g*v(<1L+yuuf&>TuE
z?BFZe@POqlaG3GKP+Zi688DVw0kO8~fU@5{NLZ+pogaX*egs}9`TsRKV$$cJZ168A
zF)`~*QW7qLTt;<5*|690AS8oS1SO~rLoxL?pd4@?l$iMm6iYq{#kJ#5EcOnZE&2a<
zIudl1*hgG3ABsg5LD^_Al=n^W9Jmomnx>$JdB{&4;UNX+5hyo))bf{5EOHFW1^)s?
z;YyAD*VCCt2QR40proSp1U!)_xYO)g>plIF&<)$fkD)jAq0ba~_
z1j@$0g;U^5umc{0B!p@>S1H0ut%p)a_FCQw*D?M%#3-uxH#$-X<}{TG$rdQSIRMwd
z+u-@|8Tb%94rTq_EFyo^Z{T_GBgo~{c?_n(ZYUSn3*~|a%Eb;rape(+B1QEbI`YBG
z@D%tuoC@ED)$lkJ1x{KnVX&F;F4zu_z#8}x+zQ`---b(@mBJh9X-Gz^x1lIlfjPuN
z=fc&J|Lt@{fgxB0Z-Tqw?XUt$!~KaF2jPfJOlrGq|H!1d4E;|bcOo2-G|40}y~K-L
zvhtB_u&7-NSY)S(37S
zK~XB3H1YN1wx7WYJMl%!R)`mpoW32Nj(CVfy0q;jB+nt+#~VqieQDCW&GfrV<6`0q
z-@d#9N>E9=43WSoH>vdnL|k+bxdf4R6C!?=){Imm68WD+ZbQC|xCn`nq@1``YQTla
zG;xkpz)FNfNOJmWC;=mFHPVE99x1n*>0F8&K&BuUAX!8sUqI4G53&i_ihK^KM?Q^6
zE!l?jBa%f|aDLKO^4y3lD-DynFI|b)9mo>o8ssy`JVe^{NPsxVUZfrAMXp6|MQ%Z+
zB2q8P?FQTFg!_<&Lp-jtlWSogawQ_U+7aicJu$_EVZ6Aid2uRoeJ@m7(rMjpBFD`o
z-77;ANQYPP?y3>9H84(Ow4*&Us560I=vSqwv}!jw6B Hd0Y}0PSRN(f@Ijl;K
zC_$%_Ph|_44dee*Eh*X+9ceczecq85rM9^ym*$y^P;8qYWc)}E`Gr9DJ7GBJ2kFgf
zyQmdvH;mil5D
zru_^mb~&DtF}f}Aopj3Kt1D7|zfoPu9YWRRr`U#S;1HtR6!54v7PH>L_fV7#aiqo#07sQp5etW2>B(~%!J
zIo3x`5XlF=XIJ7SnPV^GrR|$Wx{Yc=JL!!6s^;R#-G1mM5!D^|eQwU^5X+}q)a53{
z*}AuE%aEBIp_?un<#J+JXtAP`rJO?|Si~88>gYv5B&|wDt%y%w5`CcZ*&4nW>my))z&WC
z>3Ep}4p`5=2iiNT_blITJQFyPAFS8izLDHn)v~r_b$qh+t<&}uGOUk}&2PSF%R#Z3
zDd(Ziy54Z1Z~UnYQ*Fj8M8oJhdD51Ey1FMW=x{wl`WFnAEcEvigI>%^snkWG8F1VrCNg|Fv*4IbmQ3bMAL(w@$yiOP-
z#AL(96`PgsFflP<{fU_^ULHdf$mmZLhQP?agARp|%8^`nrb$y2+l&+R8aFagJh*Uw
zOCbz(-u2SNxA8*i#6E*+TrEd1=nzX#V8o?~D)Ea87p=6O+V!!IsRks-gvpX&pv$_(
zA1vHcyh4sF*8_1$QX2k$L6Bvx7vfMSA5k!py3kDWxaAUnrTWm5PYQk*p`ZkbeJ)%fA8SDLe)P}l(tDmgA@iXW_7dXaA9W#W#oAlqXp6ObVs+HTjmIXzei()=fUtkUSS
z4a=s~QW?s23$g7{>9_7Nr7RC|g@-d)oqq(iY0rQlQY%maQ#|6w6i|I+tORS?VkW8f27+
z27xB#B8fy3ZGyiP%68`66f{2`(RqA%;j06k-fPKcLY_{6EtRF`n?w@0{B^_nh;d
z_YOC=oL-UmA!pd@hSp6?BIc$Ua|m0XaRf?B{^ScPY>5^uZX
z9P+N(X+Wj63$^f9uo&M)-G33w@jf2KiP_|T7M=H*eKvlNN_7V5uy6({#jVKcn02UB
zZbdD`M(yMn>ZnfObR0ls>I&+)_i-_nl7BtNgW6~yhx{L=Gr)x@SVeyFa03=$2(`0*
zticbk1#jV3DeQ*x(oy|MB~HaG268_3;Wku}UPB%2J=ZkSIiGQEf{rq<26f{LsIxkb
z6*z#}@i)jO%r)fL%`d3b{(;(29{FZXW-=-xweGkcRjligJ({hkg@jS_C0?SV2cN(?
zJcSGKj(bBX>0l1C0CnFw)C0Rw69-W#--FdSfYhD2iaNRu8~wnEYpoQJGkbTF7?XkB8jr>73s##^uprY!{5)#G7cdRKz(Tx?s`9(8_dH_%o-}bjabgOA62ZMpcZliweY*B+IWbXcqD1j
z-8$jyoz)2J=}oT
zF$LB1w*0qgVJdhv-jqc0b1c&^yd`%~C=S<_MEbyQ?8OhK9+{jeM%$YTaup(yhb_
zVlAN!si_z@5oN?OLK)pgsOk5|P*0|nc#=?h*=+LXQ?JP?LbWlIP}Qp~CKe@o#%#gu
zZePW#0#wtRvXFS1=psn0NhMYjswrhjEuHzz8bZhL|5oQ-XvTIzXQ($pZQ2mYpoK5E)U?BEVN5_KMC)#vZEmPf+zo~UW}1Z~r9@3z*u-*--CHxG7=UYVK~
z3Geg=Y%A*NwY^nly&X(`-)gg+zsDRLyfXGos&jlo)8J1N&ZanT<~h#d{13CMD`(BE
zoLy_po>MoccE+sg!N2k|Q_5RCAz$3%v+Jzob|mNtjp(dg8@9dvSmm;CJQR!URJ7~5!v;;}wEV(s#W`rQmVEcDCtETo3E-Wic
Sb6za(8vM2VXsUChvg2PbyiuP3
diff --git a/Locale/deu/LC_MESSAGES/users.po b/Locale/deu/LC_MESSAGES/users.po
index 7324227d0..3793729a7 100644
--- a/Locale/deu/LC_MESSAGES/users.po
+++ b/Locale/deu/LC_MESSAGES/users.po
@@ -12,16 +12,16 @@ msgid ""
msgstr ""
"Project-Id-Version: CakeDC Users Plugin\n"
"POT-Creation-Date: 2010-09-15 15:48+0200\n"
-"PO-Revision-Date: 2011-04-28 23:38+0100\n"
+"PO-Revision-Date: 2015-09-22 12:21+0200\n"
"Last-Translator: Florian Krämer \n"
"Language-Team: Cake Development Corporation \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
-"X-Poedit-Language: German\n"
-"X-Poedit-Country: GERMANY\n"
"X-Poedit-SourceCharset: utf-8\n"
+"Language: de_DE\n"
+"X-Generator: Poedit 1.8.4\n"
#: /controllers/details_controller.php:57;138
msgid "Invalid Detail."
@@ -37,23 +37,23 @@ msgstr "%s Details gespeichert"
#: /controllers/details_controller.php:113;196
msgid "Invalid id for Detail"
-msgstr ""
+msgstr "Ungültige Id für Detail"
#: /controllers/details_controller.php:117;200
msgid "Detail deleted"
-msgstr ""
+msgstr "Detail gelöscht"
#: /controllers/details_controller.php:152;175
msgid "The Detail has been saved"
-msgstr ""
+msgstr "Das Detail wurde gespeichert"
#: /controllers/details_controller.php:155;178
msgid "The Detail could not be saved. Please, try again."
-msgstr ""
+msgstr "Das Detail konnte nicht gespeichert werden. Bitte versuche es erneut."
#: /controllers/details_controller.php:170
msgid "Invalid Detail"
-msgstr ""
+msgstr "Ungültiges Detail"
#: /controllers/users_controller.php:157
msgid "Profile saved."
@@ -77,10 +77,9 @@ msgstr "Benutzer gespeichert."
#: /controllers/users_controller.php:247
msgid "User deleted"
-msgstr ""
+msgstr "Benutzer gelöscht"
-#: /controllers/users_controller.php:249
-#: /models/user.php:703
+#: /controllers/users_controller.php:249 /models/user.php:703
msgid "Invalid User"
msgstr "Ungültiger Benutzer"
@@ -268,245 +267,181 @@ msgstr ""
msgid "floriank you have successfully logged out"
msgstr ""
-#: /views/details/add.ctp:4
-#: /views/details/admin_add.ctp:4
+#: /views/details/add.ctp:4 /views/details/admin_add.ctp:4
msgid "Add Detail"
-msgstr ""
+msgstr "Detail hinzufügen"
-#: /views/details/add.ctp:17
-#: /views/details/admin_add.ctp:17
-#: /views/details/admin_edit.ctp:19
-#: /views/details/admin_view.ctp:45
+#: /views/details/add.ctp:17 /views/details/admin_add.ctp:17
+#: /views/details/admin_edit.ctp:19 /views/details/admin_view.ctp:45
#: /views/details/view.ctp:45
msgid "List Details"
-msgstr ""
+msgstr "Details anzeigen"
-#: /views/details/add.ctp:18
-#: /views/details/admin_add.ctp:18
-#: /views/details/admin_edit.ctp:20
-#: /views/details/admin_index.ctp:67
-#: /views/details/admin_view.ctp:47
-#: /views/details/view.ctp:47
-#: /views/users/add.ctp:15
-#: /views/users/admin_add.ctp:13
-#: /views/users/admin_edit.ctp:15
-#: /views/users/admin_view.ctp:25
+#: /views/details/add.ctp:18 /views/details/admin_add.ctp:18
+#: /views/details/admin_edit.ctp:20 /views/details/admin_index.ctp:67
+#: /views/details/admin_view.ctp:47 /views/details/view.ctp:47
+#: /views/users/add.ctp:15 /views/users/admin_add.ctp:13
+#: /views/users/admin_edit.ctp:15 /views/users/admin_view.ctp:25
msgid "List Users"
-msgstr ""
+msgstr "Benutzer anzeigen"
-#: /views/details/add.ctp:19
-#: /views/details/admin_add.ctp:19
-#: /views/details/admin_edit.ctp:21
-#: /views/details/admin_index.ctp:68
-#: /views/details/admin_view.ctp:48
-#: /views/details/view.ctp:48
-#: /views/users/admin_view.ctp:26
-#: /views/users/index.ctp:46
+#: /views/details/add.ctp:19 /views/details/admin_add.ctp:19
+#: /views/details/admin_edit.ctp:21 /views/details/admin_index.ctp:68
+#: /views/details/admin_view.ctp:48 /views/details/view.ctp:48
+#: /views/users/admin_view.ctp:26 /views/users/index.ctp:46
msgid "New User"
-msgstr ""
+msgstr "Neuer Benutzer"
-#: /views/details/add.ctp:20
-#: /views/details/admin_add.ctp:20
-#: /views/details/admin_edit.ctp:22
-#: /views/details/admin_index.ctp:69
-#: /views/details/admin_view.ctp:49
-#: /views/details/view.ctp:49
+#: /views/details/add.ctp:20 /views/details/admin_add.ctp:20
+#: /views/details/admin_edit.ctp:22 /views/details/admin_index.ctp:69
+#: /views/details/admin_view.ctp:49 /views/details/view.ctp:49
msgid "List Groups"
-msgstr ""
+msgstr "Gruppen anzeigen"
-#: /views/details/add.ctp:21
-#: /views/details/admin_add.ctp:21
-#: /views/details/admin_edit.ctp:23
-#: /views/details/admin_index.ctp:70
-#: /views/details/admin_view.ctp:50;95
-#: /views/details/view.ctp:50;95
+#: /views/details/add.ctp:21 /views/details/admin_add.ctp:21
+#: /views/details/admin_edit.ctp:23 /views/details/admin_index.ctp:70
+#: /views/details/admin_view.ctp:50;95 /views/details/view.ctp:50;95
msgid "New Group"
-msgstr ""
+msgstr "Neue Gruppe"
-#: /views/details/admin_edit.ctp:4
-#: /views/details/admin_view.ctp:43
-#: /views/details/edit.ctp:5
-#: /views/details/view.ctp:43
+#: /views/details/admin_edit.ctp:4 /views/details/admin_view.ctp:43
+#: /views/details/edit.ctp:5 /views/details/view.ctp:43
msgid "Edit Detail"
-msgstr ""
+msgstr "Detail bearbeiten"
-#: /views/details/admin_edit.ctp:18
-#: /views/details/admin_index.ctp:53
-#: /views/details/admin_view.ctp:86
-#: /views/details/view.ctp:86
-#: /views/users/admin_edit.ctp:14
-#: /views/users/admin_index.ctp:47
-#: /views/users/groups.ctp:38
-#: /views/users/index.ctp:33
+#: /views/details/admin_edit.ctp:18 /views/details/admin_index.ctp:53
+#: /views/details/admin_view.ctp:86 /views/details/view.ctp:86
+#: /views/users/admin_edit.ctp:14 /views/users/admin_index.ctp:47
+#: /views/users/groups.ctp:38 /views/users/index.ctp:33
msgid "Delete"
msgstr "Löschen"
-#: /views/details/admin_edit.ctp:18
-#: /views/details/admin_index.ctp:53
-#: /views/details/admin_view.ctp:44;86
-#: /views/details/view.ctp:44;86
-#: /views/users/admin_edit.ctp:14
-#: /views/users/admin_index.ctp:47
-#: /views/users/admin_view.ctp:24
-#: /views/users/index.ctp:33
+#: /views/details/admin_edit.ctp:18 /views/details/admin_index.ctp:53
+#: /views/details/admin_view.ctp:44;86 /views/details/view.ctp:44;86
+#: /views/users/admin_edit.ctp:14 /views/users/admin_index.ctp:47
+#: /views/users/admin_view.ctp:24 /views/users/index.ctp:33
msgid "Are you sure you want to delete # %s?"
msgstr "Bist Du Dir sicher das Du %s löschen möchtest?"
-#: /views/details/admin_index.ctp:2
-#: /views/users/register.ctp:4
+#: /views/details/admin_index.ctp:2 /views/users/register.ctp:4
msgid "Details"
-msgstr ""
+msgstr "Details"
-#: /views/details/admin_index.ctp:6
-#: /views/users/index.ctp:6
+#: /views/details/admin_index.ctp:6 /views/users/index.ctp:6
msgid "Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%"
-msgstr ""
+msgstr "Seite %page% von %pages%, showing %current% records von insgesamt %count%, bei %start% anfangend und bei %end% endend"
-#: /views/details/admin_index.ctp:18
-#: /views/details/admin_view.ctp:65
-#: /views/details/view.ctp:65
-#: /views/users/admin_index.ctp:21
-#: /views/users/groups.ctp:15;50
-#: /views/users/index.ctp:13
+#: /views/details/admin_index.ctp:18 /views/details/admin_view.ctp:65
+#: /views/details/view.ctp:65 /views/users/admin_index.ctp:21
+#: /views/users/groups.ctp:15;50 /views/users/index.ctp:13
msgid "Actions"
-msgstr ""
+msgstr "Aktionen"
-#: /views/details/admin_index.ctp:51
-#: /views/details/admin_view.ctp:84
-#: /views/details/view.ctp:84
-#: /views/users/admin_index.ctp:45
+#: /views/details/admin_index.ctp:51 /views/details/admin_view.ctp:84
+#: /views/details/view.ctp:84 /views/users/admin_index.ctp:45
#: /views/users/index.ctp:31
msgid "View"
-msgstr ""
+msgstr "Ansicht"
-#: /views/details/admin_index.ctp:52
-#: /views/details/admin_view.ctp:85
-#: /views/details/view.ctp:85
-#: /views/users/admin_index.ctp:46
-#: /views/users/groups.ctp:33
-#: /views/users/index.ctp:32
+#: /views/details/admin_index.ctp:52 /views/details/admin_view.ctp:85
+#: /views/details/view.ctp:85 /views/users/admin_index.ctp:46
+#: /views/users/groups.ctp:33 /views/users/index.ctp:32
msgid "Edit"
msgstr "Bearbeiten"
-#: /views/details/admin_index.ctp:60
-#: /views/users/index.ctp:40
+#: /views/details/admin_index.ctp:60 /views/users/index.ctp:40
msgid "previous"
-msgstr ""
+msgstr "vorherige"
-#: /views/details/admin_index.ctp:62
-#: /views/users/index.ctp:42
+#: /views/details/admin_index.ctp:62 /views/users/index.ctp:42
msgid "next"
-msgstr ""
+msgstr "nächste"
-#: /views/details/admin_index.ctp:66
-#: /views/details/admin_view.ctp:46
+#: /views/details/admin_index.ctp:66 /views/details/admin_view.ctp:46
#: /views/details/view.ctp:46
msgid "New Detail"
-msgstr ""
+msgstr "Neues Detail"
-#: /views/details/admin_view.ctp:2
-#: /views/details/view.ctp:2
+#: /views/details/admin_view.ctp:2 /views/details/view.ctp:2
msgid "Detail"
-msgstr ""
+msgstr "Detail"
-#: /views/details/admin_view.ctp:4;58
-#: /views/details/view.ctp:4;58
+#: /views/details/admin_view.ctp:4;58 /views/details/view.ctp:4;58
msgid "Id"
-msgstr ""
+msgstr "Id"
-#: /views/details/admin_view.ctp:9
-#: /views/details/view.ctp:9
-#: /views/users/admin_view.ctp:2
-#: /views/users/view.ctp:2
+#: /views/details/admin_view.ctp:9 /views/details/view.ctp:9
+#: /views/users/admin_view.ctp:2 /views/users/view.ctp:2
msgid "User"
msgstr "Benutzer"
-#: /views/details/admin_view.ctp:14
-#: /views/details/view.ctp:14
+#: /views/details/admin_view.ctp:14 /views/details/view.ctp:14
msgid "Position"
-msgstr ""
+msgstr "Position"
-#: /views/details/admin_view.ctp:19
-#: /views/details/view.ctp:19
+#: /views/details/admin_view.ctp:19 /views/details/view.ctp:19
msgid "Field"
-msgstr ""
+msgstr "Feld"
-#: /views/details/admin_view.ctp:24
-#: /views/details/view.ctp:24
+#: /views/details/admin_view.ctp:24 /views/details/view.ctp:24
msgid "Value"
-msgstr ""
+msgstr "Wert"
-#: /views/details/admin_view.ctp:29;63
-#: /views/details/view.ctp:29;63
-#: /views/users/admin_view.ctp:9
-#: /views/users/view.ctp:9
+#: /views/details/admin_view.ctp:29;63 /views/details/view.ctp:29;63
+#: /views/users/admin_view.ctp:9 /views/users/view.ctp:9
msgid "Created"
-msgstr ""
+msgstr "Erstellt"
-#: /views/details/admin_view.ctp:34;64
-#: /views/details/view.ctp:34;64
+#: /views/details/admin_view.ctp:34;64 /views/details/view.ctp:34;64
#: /views/users/admin_view.ctp:14
msgid "Modified"
-msgstr ""
+msgstr "Bearbeitet"
-#: /views/details/admin_view.ctp:44
-#: /views/details/view.ctp:44
+#: /views/details/admin_view.ctp:44 /views/details/view.ctp:44
msgid "Delete Detail"
-msgstr ""
+msgstr "Detail löschen"
-#: /views/details/admin_view.ctp:54
-#: /views/details/view.ctp:54
+#: /views/details/admin_view.ctp:54 /views/details/view.ctp:54
msgid "Related Groups"
-msgstr ""
+msgstr "Ähnliche Gruppen"
-#: /views/details/admin_view.ctp:59
-#: /views/details/view.ctp:59
+#: /views/details/admin_view.ctp:59 /views/details/view.ctp:59
msgid "User Id"
-msgstr ""
+msgstr "Benutzer Id"
-#: /views/details/admin_view.ctp:60
-#: /views/details/view.ctp:60
+#: /views/details/admin_view.ctp:60 /views/details/view.ctp:60
msgid "Is Public"
-msgstr ""
+msgstr "Ist öffentlich"
-#: /views/details/admin_view.ctp:61
-#: /views/details/view.ctp:61
-#: /views/users/groups.ctp:13;47
-#: /views/users/search.ctp:9
+#: /views/details/admin_view.ctp:61 /views/details/view.ctp:61
+#: /views/users/groups.ctp:13;47 /views/users/search.ctp:9
msgid "Name"
msgstr "Name"
-#: /views/details/admin_view.ctp:62
-#: /views/details/view.ctp:62
+#: /views/details/admin_view.ctp:62 /views/details/view.ctp:62
#: /views/users/groups.ctp:48
msgid "Description"
msgstr "Beschreibung"
-#: /views/details/index.ctp:17
-#: /views/users/change_password.ctp:16
-#: /views/users/login.ctp:13
-#: /views/users/register.ctp:33;89
+#: /views/details/index.ctp:17 /views/users/change_password.ctp:16
+#: /views/users/login.ctp:13 /views/users/register.ctp:33;89
#: /views/users/request_password_change.ctp:12
#: /views/users/reset_password.ctp:14
msgid "Submit"
msgstr "Absenden"
-#: /views/elements/login.ctp:11
-#: /views/users/admin_index.ctp:10
-#: /views/users/login.ctp:8
-#: /views/users/register.ctp:71;78
+#: /views/elements/login.ctp:11 /views/users/admin_index.ctp:10
+#: /views/users/login.ctp:8 /views/users/register.ctp:71;78
#: /views/users/search.ctp:7
msgid "Email"
msgstr "Email"
-#: /views/elements/login.ctp:13
-#: /views/users/login.ctp:10
+#: /views/elements/login.ctp:13 /views/users/login.ctp:10
#: /views/users/register.ctp:19
msgid "Password"
msgstr "Passwort"
-#: /views/elements/login.ctp:15
-#: /views/users/login.ctp:1;3
+#: /views/elements/login.ctp:15 /views/users/login.ctp:1;3
msgid "Login"
msgstr "Anmeldung"
@@ -522,36 +457,30 @@ msgstr "um Deinen Account zu aktivieren mußt Du diese URL innerhalb von 24 Stun
msgid "A request to reset your password was sent. To change your password click the link below."
msgstr "Eine Anfrage um Dein Passwort zu resetten wurde gesendet. Um Dein Passwort zu ändern klicke auf den unten stehenden Link."
-#: /views/users/add.ctp:4
-#: /views/users/admin_add.ctp:4
+#: /views/users/add.ctp:4 /views/users/admin_add.ctp:4
msgid "Add User"
msgstr "Benutzer hinzufügen"
-#: /views/users/admin_edit.ctp:4
-#: /views/users/admin_view.ctp:23
+#: /views/users/admin_edit.ctp:4 /views/users/admin_view.ctp:23
#: /views/users/edit.ctp:3
msgid "Edit User"
msgstr "Benutzer bearbeiten"
-#: /views/users/admin_index.ctp:2
-#: /views/users/index.ctp:2
+#: /views/users/admin_index.ctp:2 /views/users/index.ctp:2
msgid "Users"
msgstr "Benutzer"
#: /views/users/admin_index.ctp:4
msgid "Filter"
-msgstr ""
+msgstr "Filter"
-#: /views/users/admin_index.ctp:8
-#: /views/users/admin_view.ctp:4
-#: /views/users/register.ctp:57;63
-#: /views/users/search.ctp:5
+#: /views/users/admin_index.ctp:8 /views/users/admin_view.ctp:4
+#: /views/users/register.ctp:57;63 /views/users/search.ctp:5
#: /views/users/view.ctp:4
msgid "Username"
msgstr "Benutzername"
-#: /views/users/admin_index.ctp:11
-#: /views/users/search.ctp:10
+#: /views/users/admin_index.ctp:11 /views/users/search.ctp:10
msgid "Search"
msgstr "Suche"
@@ -571,13 +500,11 @@ msgstr "Bitte gib Dein altes Passwort aus Sicherheitsgründen ein und dann gib D
msgid "Old Password"
msgstr "Altes Passwort"
-#: /views/users/change_password.ctp:11
-#: /views/users/reset_password.ctp:9
+#: /views/users/change_password.ctp:11 /views/users/reset_password.ctp:9
msgid "New Password"
msgstr "Neues Passwort"
-#: /views/users/change_password.ctp:14
-#: /views/users/reset_password.ctp:12
+#: /views/users/change_password.ctp:14 /views/users/reset_password.ctp:12
msgid "Confirm"
msgstr "Bestätigen"
@@ -587,7 +514,7 @@ msgstr "Willkommen"
#: /views/users/dashboard.ctp:3
msgid "Recent broadcasts"
-msgstr ""
+msgstr "Kürzliche Broadcast"
#: /views/users/groups.ctp:2
msgid "My Groups"
@@ -595,7 +522,7 @@ msgstr "Meine Gruppen"
#: /views/users/groups.ctp:5
msgid "Create a new group"
-msgstr ""
+msgstr "Eine neue Gruppe anlegen"
#: /views/users/groups.ctp:6
msgid "Invite a user"
@@ -603,11 +530,11 @@ msgstr "Lade einen Benutzer ein"
#: /views/users/groups.ctp:7
msgid "Requests to join"
-msgstr ""
+msgstr "Beitrittsanfragen"
#: /views/users/groups.ctp:10
msgid "My own groups"
-msgstr ""
+msgstr "Meine Gruppen"
#: /views/users/groups.ctp:14;49
msgid "Members"
@@ -619,23 +546,23 @@ msgstr "Benutzer einladen"
#: /views/users/groups.ctp:35
msgid "Manage Broadcast Scope"
-msgstr ""
+msgstr "Broadcast Score verwalten"
#: /views/users/groups.ctp:36
msgid "Access"
-msgstr ""
+msgstr "Zugang"
#: /views/users/groups.ctp:37
msgid "Addons"
-msgstr ""
+msgstr "Addons"
#: /views/users/groups.ctp:44
msgid "Groups im a member in"
-msgstr ""
+msgstr "Gruppen von denen ich ein Mitglied bin"
#: /views/users/groups.ctp:68
msgid "Leave group"
-msgstr ""
+msgstr "Gruppe verlassen"
#: /views/users/login.ctp:11
msgid "Remember Me"
@@ -675,7 +602,7 @@ msgstr "Ein Account mit dieser Email-Adresse existiert bereits"
#: /views/users/register.ctp:21
msgid "Must be at least 5 characters long"
-msgstr ""
+msgstr "Muss mindestens 5 Zeichen lang sein"
#: /views/users/register.ctp:23
msgid "Password (confirm)"
@@ -687,7 +614,7 @@ msgstr "Die Passwörter müssen gleich sein"
#: /views/users/register.ctp:29;85
msgid "I have read and agreed to "
-msgstr ""
+msgstr "Ich habe gelesen und stimme zu "
#: /views/users/register.ctp:29;85
msgid "Terms of Service"
@@ -723,4 +650,4 @@ msgstr "Nach Benutzern suchen"
#: View/Users/login.ctp:26
msgid "I forgot my password"
-msgstr "Ich habe mein Passwort vergessen"
\ No newline at end of file
+msgstr "Ich habe mein Passwort vergessen"
From 4b25a032a1c3aab5ea00b0b89606e64fe6d1f92a Mon Sep 17 00:00:00 2001
From: David Albrecht
Date: Tue, 22 Sep 2015 14:12:42 +0200
Subject: [PATCH 0192/1397] fixed typo in German message
---
Locale/deu/LC_MESSAGES/users.mo | Bin 11745 -> 11745 bytes
Locale/deu/LC_MESSAGES/users.po | 4 ++--
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Locale/deu/LC_MESSAGES/users.mo b/Locale/deu/LC_MESSAGES/users.mo
index 295f39e21fb3a5f53ec3501020ffb9f5ad89d545..9c71ac3b704cc96f6c06df1b9d186dc57138e03f 100644
GIT binary patch
delta 24
gcmaDD{V;mNXDJpFD?_8r-=%s58JBEs)rnyQ0E!w3(*OVf
delta 24
gcmaDD{V;mNXDJpVD\n"
"Language-Team: Cake Development Corporation \n"
"MIME-Version: 1.0\n"
@@ -90,7 +90,7 @@ msgstr "Du bist bereits registriert und angemeldet!"
#: /controllers/users_controller.php:282
#: /tests/cases/controllers/users_controller.test.php:194
msgid "Your account has been created. You should receive an e-mail shortly to authenticate your account. Once validated you will be able to login."
-msgstr "Dein Account wurde angelegt. Du solltest in Kürze eine Email erhalten um Deinen Account zu bestötigen. Einmal bestätigt wirst Du Dich anmelden können."
+msgstr "Dein Account wurde angelegt. Du solltest in Kürze eine Email erhalten um Deinen Account zu bestätigen. Einmal bestätigt wirst Du Dich anmelden können."
#: /controllers/users_controller.php:287
#: /tests/cases/controllers/users_controller.test.php:205
From 473b6f2d0c651028f204eeadc0f069947d9d3c3b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Tue, 22 Sep 2015 14:58:39 +0100
Subject: [PATCH 0193/1397] fix composer to stick to 3.0.x
---
composer.json | 2 +-
composer.lock | 42 +++++++++++++++++++++---------------------
2 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/composer.json b/composer.json
index 461dbe3b2..e08bc9d95 100644
--- a/composer.json
+++ b/composer.json
@@ -4,7 +4,7 @@
"type": "cakephp-plugin",
"require": {
"php": ">=5.4.16",
- "cakephp/cakephp": "~3.0"
+ "cakephp/cakephp": "~3.0.0"
},
"require-dev": {
"phpunit/phpunit": "*",
diff --git a/composer.lock b/composer.lock
index 223a588a9..78faa3434 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "042aacec48115d299cbb935ebe2d8985",
+ "hash": "213cd391e4c8a30ce4a23852a0e1f543",
"packages": [
{
"name": "aura/installer-default",
@@ -127,16 +127,16 @@
},
{
"name": "cakephp/cakephp",
- "version": "3.0.13",
+ "version": "3.0.14",
"source": {
"type": "git",
"url": "https://github.com/cakephp/cakephp.git",
- "reference": "5921b2facedbc4cdcdc4daa5f736118838796bad"
+ "reference": "3d7c826a780f6545056f351bc5aa1623b386f0c4"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/cakephp/cakephp/zipball/5921b2facedbc4cdcdc4daa5f736118838796bad",
- "reference": "5921b2facedbc4cdcdc4daa5f736118838796bad",
+ "url": "https://api.github.com/repos/cakephp/cakephp/zipball/3d7c826a780f6545056f351bc5aa1623b386f0c4",
+ "reference": "3d7c826a780f6545056f351bc5aa1623b386f0c4",
"shasum": ""
},
"require": {
@@ -198,7 +198,7 @@
"keywords": [
"framework"
],
- "time": "2015-09-07 01:53:22"
+ "time": "2015-09-22 02:12:36"
},
{
"name": "ircmaxell/password-compat",
@@ -634,16 +634,16 @@
},
{
"name": "phpunit/php-code-coverage",
- "version": "2.2.2",
+ "version": "2.2.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "2d7c03c0e4e080901b8f33b2897b0577be18a13c"
+ "reference": "ef1ca6835468857944d5c3b48fa503d5554cff2f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2d7c03c0e4e080901b8f33b2897b0577be18a13c",
- "reference": "2d7c03c0e4e080901b8f33b2897b0577be18a13c",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef1ca6835468857944d5c3b48fa503d5554cff2f",
+ "reference": "ef1ca6835468857944d5c3b48fa503d5554cff2f",
"shasum": ""
},
"require": {
@@ -692,7 +692,7 @@
"testing",
"xunit"
],
- "time": "2015-08-04 03:42:39"
+ "time": "2015-09-14 06:51:16"
},
{
"name": "phpunit/php-file-iterator",
@@ -825,16 +825,16 @@
},
{
"name": "phpunit/php-token-stream",
- "version": "1.4.6",
+ "version": "1.4.8",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
- "reference": "3ab72c62e550370a6cd5dc873e1a04ab57562f5b"
+ "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3ab72c62e550370a6cd5dc873e1a04ab57562f5b",
- "reference": "3ab72c62e550370a6cd5dc873e1a04ab57562f5b",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
+ "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
"shasum": ""
},
"require": {
@@ -870,20 +870,20 @@
"keywords": [
"tokenizer"
],
- "time": "2015-08-16 08:51:00"
+ "time": "2015-09-15 10:49:45"
},
{
"name": "phpunit/phpunit",
- "version": "4.8.6",
+ "version": "4.8.9",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "2246830f4a1a551c67933e4171bf2126dc29d357"
+ "reference": "73fad41adb5b7bc3a494bb930d90648df1d5e74b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2246830f4a1a551c67933e4171bf2126dc29d357",
- "reference": "2246830f4a1a551c67933e4171bf2126dc29d357",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/73fad41adb5b7bc3a494bb930d90648df1d5e74b",
+ "reference": "73fad41adb5b7bc3a494bb930d90648df1d5e74b",
"shasum": ""
},
"require": {
@@ -942,7 +942,7 @@
"testing",
"xunit"
],
- "time": "2015-08-24 04:09:38"
+ "time": "2015-09-20 12:56:44"
},
{
"name": "phpunit/phpunit-mock-objects",
From 09ebdc5fd6f86d5def8f50abd759723057c1fab9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Tue, 22 Sep 2015 14:59:18 +0100
Subject: [PATCH 0194/1397] remove lock file
---
composer.lock | 1433 -------------------------------------------------
1 file changed, 1433 deletions(-)
delete mode 100644 composer.lock
diff --git a/composer.lock b/composer.lock
deleted file mode 100644
index 78faa3434..000000000
--- a/composer.lock
+++ /dev/null
@@ -1,1433 +0,0 @@
-{
- "_readme": [
- "This file locks the dependencies of your project to a known state",
- "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
- "This file is @generated automatically"
- ],
- "hash": "213cd391e4c8a30ce4a23852a0e1f543",
- "packages": [
- {
- "name": "aura/installer-default",
- "version": "1.0.0",
- "source": {
- "type": "git",
- "url": "https://github.com/auraphp/installer-default.git",
- "reference": "52f8de3670cc1ef45a916f40f732937436d028c8"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/auraphp/installer-default/zipball/52f8de3670cc1ef45a916f40f732937436d028c8",
- "reference": "52f8de3670cc1ef45a916f40f732937436d028c8",
- "shasum": ""
- },
- "type": "composer-installer",
- "extra": {
- "class": "Aura\\Composer\\DefaultInstaller"
- },
- "autoload": {
- "psr-0": {
- "Aura\\Composer\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-2-Clause"
- ],
- "authors": [
- {
- "name": "Paul M. Jones",
- "email": "pmjones88@gmail.com",
- "homepage": "http://paul-m-jones.com"
- }
- ],
- "description": "Installs Aura packages using the Composer defaults.",
- "keywords": [
- "aura",
- "installer"
- ],
- "time": "2012-11-26 21:35:57"
- },
- {
- "name": "aura/intl",
- "version": "1.1.1",
- "source": {
- "type": "git",
- "url": "https://github.com/auraphp/Aura.Intl.git",
- "reference": "c5fe620167550ad6fa77dd3570fba2efc77a2a21"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/auraphp/Aura.Intl/zipball/c5fe620167550ad6fa77dd3570fba2efc77a2a21",
- "reference": "c5fe620167550ad6fa77dd3570fba2efc77a2a21",
- "shasum": ""
- },
- "require": {
- "aura/installer-default": "1.0.*",
- "php": ">=5.4.0"
- },
- "type": "aura-package",
- "extra": {
- "aura": {
- "type": "library",
- "config": {
- "common": "Aura\\Intl\\_Config\\Common"
- }
- },
- "branch-alias": {
- "dev-develop": "1.1.x-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "Aura\\Intl": "src/"
- },
- "psr-4": {
- "Aura\\Intl\\_Config\\": "config/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-2-Clause"
- ],
- "authors": [
- {
- "name": "Paul M. Jones",
- "email": "pmjones88@gmail.com",
- "homepage": "http://paul-m-jones.com"
- },
- {
- "name": "Aura.Intl Contributors",
- "homepage": "https://github.com/auraphp/Aura.Intl/contributors"
- },
- {
- "name": "Pascal Borreli",
- "email": "pascal@borreli.com"
- },
- {
- "name": "Mapthegod",
- "email": "mapthegod@gmail.com"
- },
- {
- "name": "Jose Lorenzo Rodriguez",
- "email": "jose.zap@gmail.com"
- }
- ],
- "description": "The Aura.Intl package provides internationalization (I18N) tools, specifically\npackage-oriented per-locale message translation.",
- "homepage": "http://auraphp.com/Aura.Intl",
- "keywords": [
- "g11n",
- "globalization",
- "i18n",
- "internationalization",
- "intl",
- "l10n",
- "localization"
- ],
- "time": "2014-08-24 00:00:00"
- },
- {
- "name": "cakephp/cakephp",
- "version": "3.0.14",
- "source": {
- "type": "git",
- "url": "https://github.com/cakephp/cakephp.git",
- "reference": "3d7c826a780f6545056f351bc5aa1623b386f0c4"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/cakephp/cakephp/zipball/3d7c826a780f6545056f351bc5aa1623b386f0c4",
- "reference": "3d7c826a780f6545056f351bc5aa1623b386f0c4",
- "shasum": ""
- },
- "require": {
- "aura/intl": "1.1.*",
- "ext-intl": "*",
- "ext-mbstring": "*",
- "ircmaxell/password-compat": "1.0.*",
- "nesbot/carbon": "1.13.*",
- "php": ">=5.4.16",
- "psr/log": "1.0"
- },
- "replace": {
- "cakephp/cache": "self.version",
- "cakephp/collection": "self.version",
- "cakephp/core": "self.version",
- "cakephp/database": "self.version",
- "cakephp/datasource": "self.version",
- "cakephp/event": "self.version",
- "cakephp/filesystem": "self.version",
- "cakephp/i18n": "self.version",
- "cakephp/log": "self.version",
- "cakephp/orm": "self.version",
- "cakephp/utility": "self.version",
- "cakephp/validation": "self.version"
- },
- "require-dev": {
- "cakephp/cakephp-codesniffer": "dev-master",
- "phpunit/phpunit": "*"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "3.0.x-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Cake\\": "src"
- },
- "files": [
- "src/Core/functions.php",
- "src/Collection/functions.php",
- "src/I18n/functions.php",
- "src/Utility/bootstrap.php"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "CakePHP Community",
- "homepage": "https://github.com/cakephp/cakephp/graphs/contributors"
- }
- ],
- "description": "The CakePHP framework",
- "homepage": "http://cakephp.org",
- "keywords": [
- "framework"
- ],
- "time": "2015-09-22 02:12:36"
- },
- {
- "name": "ircmaxell/password-compat",
- "version": "v1.0.4",
- "source": {
- "type": "git",
- "url": "https://github.com/ircmaxell/password_compat.git",
- "reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/5c5cde8822a69545767f7c7f3058cb15ff84614c",
- "reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c",
- "shasum": ""
- },
- "require-dev": {
- "phpunit/phpunit": "4.*"
- },
- "type": "library",
- "autoload": {
- "files": [
- "lib/password.php"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Anthony Ferrara",
- "email": "ircmaxell@php.net",
- "homepage": "http://blog.ircmaxell.com"
- }
- ],
- "description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash",
- "homepage": "https://github.com/ircmaxell/password_compat",
- "keywords": [
- "hashing",
- "password"
- ],
- "time": "2014-11-20 16:49:30"
- },
- {
- "name": "nesbot/carbon",
- "version": "1.13.0",
- "source": {
- "type": "git",
- "url": "https://github.com/briannesbitt/Carbon.git",
- "reference": "5cb6e71055f7b0b57956b73d324cc4de31278f42"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/5cb6e71055f7b0b57956b73d324cc4de31278f42",
- "reference": "5cb6e71055f7b0b57956b73d324cc4de31278f42",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.0"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.0"
- },
- "type": "library",
- "autoload": {
- "psr-0": {
- "Carbon": "src"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Brian Nesbitt",
- "email": "brian@nesbot.com",
- "homepage": "http://nesbot.com"
- }
- ],
- "description": "A simple API extension for DateTime.",
- "homepage": "https://github.com/briannesbitt/Carbon",
- "keywords": [
- "date",
- "datetime",
- "time"
- ],
- "time": "2014-09-26 02:52:02"
- },
- {
- "name": "psr/log",
- "version": "1.0.0",
- "source": {
- "type": "git",
- "url": "https://github.com/php-fig/log.git",
- "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b",
- "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b",
- "shasum": ""
- },
- "type": "library",
- "autoload": {
- "psr-0": {
- "Psr\\Log\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "PHP-FIG",
- "homepage": "http://www.php-fig.org/"
- }
- ],
- "description": "Common interface for logging libraries",
- "keywords": [
- "log",
- "psr",
- "psr-3"
- ],
- "time": "2012-12-21 11:40:51"
- }
- ],
- "packages-dev": [
- {
- "name": "doctrine/instantiator",
- "version": "1.0.5",
- "source": {
- "type": "git",
- "url": "https://github.com/doctrine/instantiator.git",
- "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d",
- "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3,<8.0-DEV"
- },
- "require-dev": {
- "athletic/athletic": "~0.1.8",
- "ext-pdo": "*",
- "ext-phar": "*",
- "phpunit/phpunit": "~4.0",
- "squizlabs/php_codesniffer": "~2.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0.x-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Marco Pivetta",
- "email": "ocramius@gmail.com",
- "homepage": "http://ocramius.github.com/"
- }
- ],
- "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
- "homepage": "https://github.com/doctrine/instantiator",
- "keywords": [
- "constructor",
- "instantiate"
- ],
- "time": "2015-06-14 21:17:01"
- },
- {
- "name": "opauth/facebook",
- "version": "0.2.1",
- "source": {
- "type": "git",
- "url": "https://github.com/opauth/facebook.git",
- "reference": "28c0e53393a03a66cbfea03073d1d6aacfaddb69"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/opauth/facebook/zipball/28c0e53393a03a66cbfea03073d1d6aacfaddb69",
- "reference": "28c0e53393a03a66cbfea03073d1d6aacfaddb69",
- "shasum": ""
- },
- "require": {
- "opauth/opauth": ">=0.2.0",
- "php": ">=5.2.0"
- },
- "type": "library",
- "autoload": {
- "psr-0": {
- "": "."
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "U-Zyn Chua",
- "email": "chua@uzyn.com",
- "homepage": "http://uzyn.com"
- }
- ],
- "description": "Facebook strategy for Opauth",
- "homepage": "http://opauth.org",
- "keywords": [
- "Authentication",
- "auth",
- "facebook"
- ],
- "time": "2012-09-21 04:47:35"
- },
- {
- "name": "opauth/opauth",
- "version": "0.4.4",
- "source": {
- "type": "git",
- "url": "https://github.com/opauth/opauth.git",
- "reference": "436fb98c2374c9e8ae4d8adddf83214bee4d9c72"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/opauth/opauth/zipball/436fb98c2374c9e8ae4d8adddf83214bee4d9c72",
- "reference": "436fb98c2374c9e8ae4d8adddf83214bee4d9c72",
- "shasum": ""
- },
- "require": {
- "php": ">=5.2.0"
- },
- "suggest": {
- "opauth/facebook": "Allows Facebook authentication",
- "opauth/google": "Allows Google authentication",
- "opauth/twitter": "Allows Twitter authentication"
- },
- "type": "library",
- "autoload": {
- "classmap": [
- "lib/Opauth/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "U-Zyn Chua",
- "email": "chua@uzyn.com",
- "homepage": "http://uzyn.com"
- }
- ],
- "description": "Multi-provider authentication framework for PHP",
- "homepage": "http://opauth.org",
- "keywords": [
- "Authentication",
- "OpenId",
- "auth",
- "facebook",
- "google",
- "oauth",
- "omniauth",
- "twitter"
- ],
- "time": "2013-05-10 09:01:52"
- },
- {
- "name": "opauth/twitter",
- "version": "0.3.1",
- "source": {
- "type": "git",
- "url": "https://github.com/opauth/twitter.git",
- "reference": "24792d512ccc67e7d11e9249737616f039551c11"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/opauth/twitter/zipball/24792d512ccc67e7d11e9249737616f039551c11",
- "reference": "24792d512ccc67e7d11e9249737616f039551c11",
- "shasum": ""
- },
- "require": {
- "opauth/opauth": ">=0.2.0",
- "php": ">=5.2.0"
- },
- "type": "library",
- "autoload": {
- "psr-0": {
- "": "."
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "U-Zyn Chua",
- "email": "chua@uzyn.com",
- "homepage": "http://uzyn.com"
- }
- ],
- "description": "Twitter strategy for Opauth",
- "homepage": "http://opauth.org",
- "keywords": [
- "Authentication",
- "auth",
- "twitter"
- ],
- "time": "2013-06-12 07:50:11"
- },
- {
- "name": "phpdocumentor/reflection-docblock",
- "version": "2.0.4",
- "source": {
- "type": "git",
- "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
- "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8",
- "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.0"
- },
- "suggest": {
- "dflydev/markdown": "~1.0",
- "erusev/parsedown": "~1.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.0.x-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "phpDocumentor": [
- "src/"
- ]
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Mike van Riel",
- "email": "mike.vanriel@naenius.com"
- }
- ],
- "time": "2015-02-03 12:10:50"
- },
- {
- "name": "phpspec/prophecy",
- "version": "v1.5.0",
- "source": {
- "type": "git",
- "url": "https://github.com/phpspec/prophecy.git",
- "reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4745ded9307786b730d7a60df5cb5a6c43cf95f7",
- "reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7",
- "shasum": ""
- },
- "require": {
- "doctrine/instantiator": "^1.0.2",
- "phpdocumentor/reflection-docblock": "~2.0",
- "sebastian/comparator": "~1.1"
- },
- "require-dev": {
- "phpspec/phpspec": "~2.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.4.x-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "Prophecy\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Konstantin Kudryashov",
- "email": "ever.zet@gmail.com",
- "homepage": "http://everzet.com"
- },
- {
- "name": "Marcello Duarte",
- "email": "marcello.duarte@gmail.com"
- }
- ],
- "description": "Highly opinionated mocking framework for PHP 5.3+",
- "homepage": "https://github.com/phpspec/prophecy",
- "keywords": [
- "Double",
- "Dummy",
- "fake",
- "mock",
- "spy",
- "stub"
- ],
- "time": "2015-08-13 10:07:40"
- },
- {
- "name": "phpunit/php-code-coverage",
- "version": "2.2.3",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "ef1ca6835468857944d5c3b48fa503d5554cff2f"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef1ca6835468857944d5c3b48fa503d5554cff2f",
- "reference": "ef1ca6835468857944d5c3b48fa503d5554cff2f",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3",
- "phpunit/php-file-iterator": "~1.3",
- "phpunit/php-text-template": "~1.2",
- "phpunit/php-token-stream": "~1.3",
- "sebastian/environment": "^1.3.2",
- "sebastian/version": "~1.0"
- },
- "require-dev": {
- "ext-xdebug": ">=2.1.4",
- "phpunit/phpunit": "~4"
- },
- "suggest": {
- "ext-dom": "*",
- "ext-xdebug": ">=2.2.1",
- "ext-xmlwriter": "*"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.2.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sb@sebastian-bergmann.de",
- "role": "lead"
- }
- ],
- "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
- "homepage": "https://github.com/sebastianbergmann/php-code-coverage",
- "keywords": [
- "coverage",
- "testing",
- "xunit"
- ],
- "time": "2015-09-14 06:51:16"
- },
- {
- "name": "phpunit/php-file-iterator",
- "version": "1.4.1",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-file-iterator.git",
- "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0",
- "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.4.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sb@sebastian-bergmann.de",
- "role": "lead"
- }
- ],
- "description": "FilterIterator implementation that filters files based on a list of suffixes.",
- "homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
- "keywords": [
- "filesystem",
- "iterator"
- ],
- "time": "2015-06-21 13:08:43"
- },
- {
- "name": "phpunit/php-text-template",
- "version": "1.2.1",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-text-template.git",
- "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
- "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "type": "library",
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "Simple template engine.",
- "homepage": "https://github.com/sebastianbergmann/php-text-template/",
- "keywords": [
- "template"
- ],
- "time": "2015-06-21 13:50:34"
- },
- {
- "name": "phpunit/php-timer",
- "version": "1.0.7",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-timer.git",
- "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b",
- "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "type": "library",
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sb@sebastian-bergmann.de",
- "role": "lead"
- }
- ],
- "description": "Utility class for timing",
- "homepage": "https://github.com/sebastianbergmann/php-timer/",
- "keywords": [
- "timer"
- ],
- "time": "2015-06-21 08:01:12"
- },
- {
- "name": "phpunit/php-token-stream",
- "version": "1.4.8",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-token-stream.git",
- "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
- "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
- "shasum": ""
- },
- "require": {
- "ext-tokenizer": "*",
- "php": ">=5.3.3"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.2"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.4-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Wrapper around PHP's tokenizer extension.",
- "homepage": "https://github.com/sebastianbergmann/php-token-stream/",
- "keywords": [
- "tokenizer"
- ],
- "time": "2015-09-15 10:49:45"
- },
- {
- "name": "phpunit/phpunit",
- "version": "4.8.9",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "73fad41adb5b7bc3a494bb930d90648df1d5e74b"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/73fad41adb5b7bc3a494bb930d90648df1d5e74b",
- "reference": "73fad41adb5b7bc3a494bb930d90648df1d5e74b",
- "shasum": ""
- },
- "require": {
- "ext-dom": "*",
- "ext-json": "*",
- "ext-pcre": "*",
- "ext-reflection": "*",
- "ext-spl": "*",
- "php": ">=5.3.3",
- "phpspec/prophecy": "^1.3.1",
- "phpunit/php-code-coverage": "~2.1",
- "phpunit/php-file-iterator": "~1.4",
- "phpunit/php-text-template": "~1.2",
- "phpunit/php-timer": ">=1.0.6",
- "phpunit/phpunit-mock-objects": "~2.3",
- "sebastian/comparator": "~1.1",
- "sebastian/diff": "~1.2",
- "sebastian/environment": "~1.3",
- "sebastian/exporter": "~1.2",
- "sebastian/global-state": "~1.0",
- "sebastian/version": "~1.0",
- "symfony/yaml": "~2.1|~3.0"
- },
- "suggest": {
- "phpunit/php-invoker": "~1.1"
- },
- "bin": [
- "phpunit"
- ],
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "4.8.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "The PHP Unit Testing framework.",
- "homepage": "https://phpunit.de/",
- "keywords": [
- "phpunit",
- "testing",
- "xunit"
- ],
- "time": "2015-09-20 12:56:44"
- },
- {
- "name": "phpunit/phpunit-mock-objects",
- "version": "2.3.7",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
- "reference": "5e2645ad49d196e020b85598d7c97e482725786a"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5e2645ad49d196e020b85598d7c97e482725786a",
- "reference": "5e2645ad49d196e020b85598d7c97e482725786a",
- "shasum": ""
- },
- "require": {
- "doctrine/instantiator": "^1.0.2",
- "php": ">=5.3.3",
- "phpunit/php-text-template": "~1.2",
- "sebastian/exporter": "~1.2"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.4"
- },
- "suggest": {
- "ext-soap": "*"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.3.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sb@sebastian-bergmann.de",
- "role": "lead"
- }
- ],
- "description": "Mock Object library for PHPUnit",
- "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
- "keywords": [
- "mock",
- "xunit"
- ],
- "time": "2015-08-19 09:14:08"
- },
- {
- "name": "sebastian/comparator",
- "version": "1.2.0",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/comparator.git",
- "reference": "937efb279bd37a375bcadf584dec0726f84dbf22"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22",
- "reference": "937efb279bd37a375bcadf584dec0726f84dbf22",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3",
- "sebastian/diff": "~1.2",
- "sebastian/exporter": "~1.2"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.4"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.2.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Jeff Welch",
- "email": "whatthejeff@gmail.com"
- },
- {
- "name": "Volker Dusch",
- "email": "github@wallbash.com"
- },
- {
- "name": "Bernhard Schussek",
- "email": "bschussek@2bepublished.at"
- },
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Provides the functionality to compare PHP values for equality",
- "homepage": "http://www.github.com/sebastianbergmann/comparator",
- "keywords": [
- "comparator",
- "compare",
- "equality"
- ],
- "time": "2015-07-26 15:48:44"
- },
- {
- "name": "sebastian/diff",
- "version": "1.3.0",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/diff.git",
- "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3",
- "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.2"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.3-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Kore Nordmann",
- "email": "mail@kore-nordmann.de"
- },
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Diff implementation",
- "homepage": "http://www.github.com/sebastianbergmann/diff",
- "keywords": [
- "diff"
- ],
- "time": "2015-02-22 15:13:53"
- },
- {
- "name": "sebastian/environment",
- "version": "1.3.2",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/environment.git",
- "reference": "6324c907ce7a52478eeeaede764f48733ef5ae44"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6324c907ce7a52478eeeaede764f48733ef5ae44",
- "reference": "6324c907ce7a52478eeeaede764f48733ef5ae44",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.4"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.3.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Provides functionality to handle HHVM/PHP environments",
- "homepage": "http://www.github.com/sebastianbergmann/environment",
- "keywords": [
- "Xdebug",
- "environment",
- "hhvm"
- ],
- "time": "2015-08-03 06:14:51"
- },
- {
- "name": "sebastian/exporter",
- "version": "1.2.1",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/exporter.git",
- "reference": "7ae5513327cb536431847bcc0c10edba2701064e"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/7ae5513327cb536431847bcc0c10edba2701064e",
- "reference": "7ae5513327cb536431847bcc0c10edba2701064e",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3",
- "sebastian/recursion-context": "~1.0"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.4"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.2.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Jeff Welch",
- "email": "whatthejeff@gmail.com"
- },
- {
- "name": "Volker Dusch",
- "email": "github@wallbash.com"
- },
- {
- "name": "Bernhard Schussek",
- "email": "bschussek@2bepublished.at"
- },
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- },
- {
- "name": "Adam Harvey",
- "email": "aharvey@php.net"
- }
- ],
- "description": "Provides the functionality to export PHP variables for visualization",
- "homepage": "http://www.github.com/sebastianbergmann/exporter",
- "keywords": [
- "export",
- "exporter"
- ],
- "time": "2015-06-21 07:55:53"
- },
- {
- "name": "sebastian/global-state",
- "version": "1.0.0",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/global-state.git",
- "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01",
- "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.2"
- },
- "suggest": {
- "ext-uopz": "*"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Snapshotting of global state",
- "homepage": "http://www.github.com/sebastianbergmann/global-state",
- "keywords": [
- "global state"
- ],
- "time": "2014-10-06 09:23:50"
- },
- {
- "name": "sebastian/recursion-context",
- "version": "1.0.1",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/recursion-context.git",
- "reference": "994d4a811bafe801fb06dccbee797863ba2792ba"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/994d4a811bafe801fb06dccbee797863ba2792ba",
- "reference": "994d4a811bafe801fb06dccbee797863ba2792ba",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.4"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Jeff Welch",
- "email": "whatthejeff@gmail.com"
- },
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- },
- {
- "name": "Adam Harvey",
- "email": "aharvey@php.net"
- }
- ],
- "description": "Provides functionality to recursively process PHP variables",
- "homepage": "http://www.github.com/sebastianbergmann/recursion-context",
- "time": "2015-06-21 08:04:50"
- },
- {
- "name": "sebastian/version",
- "version": "1.0.6",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/version.git",
- "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6",
- "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6",
- "shasum": ""
- },
- "type": "library",
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "Library that helps with managing the version number of Git-hosted PHP projects",
- "homepage": "https://github.com/sebastianbergmann/version",
- "time": "2015-06-21 13:59:46"
- },
- {
- "name": "symfony/yaml",
- "version": "v2.7.4",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/Yaml.git",
- "reference": "2dc7b06c065df96cc686c66da2705e5e18aef661"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/Yaml/zipball/2dc7b06c065df96cc686c66da2705e5e18aef661",
- "reference": "2dc7b06c065df96cc686c66da2705e5e18aef661",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.9"
- },
- "require-dev": {
- "symfony/phpunit-bridge": "~2.7"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.7-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Symfony\\Component\\Yaml\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony Yaml Component",
- "homepage": "https://symfony.com",
- "time": "2015-08-24 07:13:45"
- }
- ],
- "aliases": [],
- "minimum-stability": "stable",
- "stability-flags": [],
- "prefer-stable": false,
- "prefer-lowest": false,
- "platform": {
- "php": ">=5.4.16"
- },
- "platform-dev": []
-}
From 6c6f2c7d7ee68a12d4dfa33fae17341960a774e0 Mon Sep 17 00:00:00 2001
From: Alejandro Ibarra
Date: Tue, 22 Sep 2015 17:33:16 -0500
Subject: [PATCH 0195/1397] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index ad114812f..995bc29d1 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
CakeDC Users Plugin
===================
-[](http://travis-ci.org/CakeDC/users)
+[](http://travis-ci.org/CakeDC/users)
[](https://packagist.org/packages/CakeDC/users)
[](https://packagist.org/packages/CakeDC/users)
From 2871193cd8620e278e7c4088e5e83bcfe8ccf5e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20M=2E=20Gonz=C3=A1lez=20Mart=C3=ADn?=
Date: Tue, 22 Sep 2015 23:53:37 +0100
Subject: [PATCH 0196/1397] Update README.md
---
README.md | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index 995bc29d1..3f49668bd 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ CakeDC Users Plugin
[](https://packagist.org/packages/CakeDC/users)
[](https://packagist.org/packages/CakeDC/users)
-IMPORTANT: 3.x version is BETA status now, we are still improving and testing it.
+IMPORTANT: 3.0.x version is BETA status now, we are still improving and testing it.
The **Users** plugin is back!
@@ -34,7 +34,7 @@ Another decision made was limiting the plugin dependencies on other packages as
Requirements
------------
-* CakePHP 3.0+
+* CakePHP 3.0.*
* PHP 5.4.16+
Documentation
@@ -45,15 +45,15 @@ For documentation, as well as tutorials, see the [Docs](Docs/Home.md) directory
Roadmap
------
-* 3.0.0 Migration to CakePHP 3.x
-* 3.0.1 General improvements
+* 3.0.2 Add google authentication
+ * Improve unit test coverage
+* YOU ARE HERE > 3.0.1 General improvements
* Unit test coverage improvements
* Refactor UsersTable to Behavior
* Add google authentication
* Add reCaptcha
* Link social accounts in profile
-* 3.0.2 Add google authentication
- * Improve unit test coverage
+* 3.0.0 Migration to CakePHP 3.0
Support
-------
From ced51e0c63a585ba59372354115644d81de5ee00 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20M=2E=20Gonz=C3=A1lez=20Mart=C3=ADn?=
Date: Tue, 22 Sep 2015 23:54:28 +0100
Subject: [PATCH 0197/1397] Update Home.md
---
Docs/Home.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Docs/Home.md b/Docs/Home.md
index 3ae1db423..293762fda 100644
--- a/Docs/Home.md
+++ b/Docs/Home.md
@@ -13,7 +13,7 @@ That it works out of the box doesn't mean it is thought to be used exactly like
Requirements
------------
-* CakePHP 3.0+
+* CakePHP 3.0.*
* PHP 5.4.16+
Documentation
From 7d255656a244fe720565e075b1023feac11474e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20M=2E=20Gonz=C3=A1lez=20Mart=C3=ADn?=
Date: Tue, 22 Sep 2015 23:55:53 +0100
Subject: [PATCH 0198/1397] Update Installation.md
---
Docs/Documentation/Installation.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Docs/Documentation/Installation.md b/Docs/Documentation/Installation.md
index f44ff1148..c6c16960f 100644
--- a/Docs/Documentation/Installation.md
+++ b/Docs/Documentation/Installation.md
@@ -5,7 +5,7 @@ Composer
------
```
-composer require cakedc/users:~3.0
+composer require cakedc/users:3.0.*
```
if you want to use social login features...
From 930a6834b31365d89170ec697bdb584057018a59 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20M=2E=20Gonz=C3=A1lez=20Mart=C3=ADn?=
Date: Wed, 23 Sep 2015 00:01:00 +0100
Subject: [PATCH 0199/1397] Update README.md
---
README.md | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 3f49668bd..37482c153 100644
--- a/README.md
+++ b/README.md
@@ -45,15 +45,16 @@ For documentation, as well as tutorials, see the [Docs](Docs/Home.md) directory
Roadmap
------
-* 3.0.2 Add google authentication
+* 3.0.2
+ * Add Google authentication
+ * Add Instagram authentication
* Improve unit test coverage
-* YOU ARE HERE > 3.0.1 General improvements
+* YOU ARE HERE > 3.0.0 Migration to CakePHP 3.0
* Unit test coverage improvements
* Refactor UsersTable to Behavior
* Add google authentication
* Add reCaptcha
* Link social accounts in profile
-* 3.0.0 Migration to CakePHP 3.0
Support
-------
From be4b189e17b84b97481b5c4557d4ad49cd623292 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Wed, 23 Sep 2015 00:13:43 +0100
Subject: [PATCH 0200/1397] update composer to use cake 3.1
---
composer.json | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/composer.json b/composer.json
index e08bc9d95..cb6dfb871 100644
--- a/composer.json
+++ b/composer.json
@@ -1,10 +1,10 @@
{
"name": "cakedc/users",
- "description": "Users plugin for CakePHP 3.x",
+ "description": "Users plugin for CakePHP 3.1",
"type": "cakephp-plugin",
"require": {
"php": ">=5.4.16",
- "cakephp/cakephp": "~3.0.0"
+ "cakephp/cakephp": "~3.1.0"
},
"require-dev": {
"phpunit/phpunit": "*",
From 4b497519014fe2171a3d225e5287777dcb54893a Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Tue, 22 Sep 2015 23:32:36 +0000
Subject: [PATCH 0201/1397] fix Email class for cake 3.1 and new flash message
structure
---
src/Model/Behavior/Behavior.php | 2 +-
src/Model/Behavior/PasswordBehavior.php | 2 +-
src/Model/Behavior/SocialAccountBehavior.php | 2 +-
src/Model/Table/SocialAccountsTable.php | 2 +-
src/Model/Table/UsersTable.php | 2 +-
.../Controller/SocialAccountsControllerTest.php | 16 ++++++++--------
.../TestCase/Controller/Traits/BaseTraitTest.php | 2 +-
.../Controller/Traits/RegisterTraitTest.php | 2 +-
.../Model/Behavior/PasswordBehaviorTest.php | 2 +-
.../Model/Behavior/RegisterBehaviorTest.php | 2 +-
.../Model/Behavior/SocialAccountBehaviorTest.php | 2 +-
.../Model/Table/SocialAccountsTableTest.php | 2 +-
tests/TestCase/Model/Table/UsersTableTest.php | 2 +-
13 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/src/Model/Behavior/Behavior.php b/src/Model/Behavior/Behavior.php
index a8379b076..d0307d980 100644
--- a/src/Model/Behavior/Behavior.php
+++ b/src/Model/Behavior/Behavior.php
@@ -13,7 +13,7 @@
use Cake\Datasource\EntityInterface;
use Cake\I18n\Time;
-use Cake\Network\Email\Email;
+use Cake\Mailer\Email;
use Cake\ORM\Behavior as BaseBehavior;
/**
diff --git a/src/Model/Behavior/PasswordBehavior.php b/src/Model/Behavior/PasswordBehavior.php
index 76b4a2d42..fc87c150d 100644
--- a/src/Model/Behavior/PasswordBehavior.php
+++ b/src/Model/Behavior/PasswordBehavior.php
@@ -16,7 +16,7 @@
use CakeDC\Users\Exception\WrongPasswordException;
use CakeDC\Users\Model\Behavior\Behavior;
use Cake\Datasource\EntityInterface;
-use Cake\Network\Email\Email;
+use Cake\Mailer\Email;
use Cake\Utility\Hash;
use InvalidArgumentException;
diff --git a/src/Model/Behavior/SocialAccountBehavior.php b/src/Model/Behavior/SocialAccountBehavior.php
index e9cf6d3eb..8b37502b2 100644
--- a/src/Model/Behavior/SocialAccountBehavior.php
+++ b/src/Model/Behavior/SocialAccountBehavior.php
@@ -21,7 +21,7 @@
use Cake\Datasource\EntityInterface;
use Cake\Datasource\Exception\RecordNotFoundException;
use Cake\Event\Event;
-use Cake\Network\Email\Email;
+use Cake\Mailer\Email;
use Cake\ORM\Entity;
use InvalidArgumentException;
diff --git a/src/Model/Table/SocialAccountsTable.php b/src/Model/Table/SocialAccountsTable.php
index 50f953e0f..4b139e415 100644
--- a/src/Model/Table/SocialAccountsTable.php
+++ b/src/Model/Table/SocialAccountsTable.php
@@ -18,7 +18,7 @@
use Cake\Datasource\EntityInterface;
use Cake\Datasource\Exception\RecordNotFoundException;
use Cake\Event\Event;
-use Cake\Network\Email\Email;
+use Cake\Mailer\Email;
use Cake\ORM\Entity;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
diff --git a/src/Model/Table/UsersTable.php b/src/Model/Table/UsersTable.php
index 1c33e92f6..ca088f1e2 100644
--- a/src/Model/Table/UsersTable.php
+++ b/src/Model/Table/UsersTable.php
@@ -14,7 +14,7 @@
use CakeDC\Users\Exception\WrongPasswordException;
use CakeDC\Users\Model\Entity\User;
use Cake\Datasource\EntityInterface;
-use Cake\Network\Email\Email;
+use Cake\Mailer\Email;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Utility\Hash;
diff --git a/tests/TestCase/Controller/SocialAccountsControllerTest.php b/tests/TestCase/Controller/SocialAccountsControllerTest.php
index 7f4c6a714..7b269638a 100644
--- a/tests/TestCase/Controller/SocialAccountsControllerTest.php
+++ b/tests/TestCase/Controller/SocialAccountsControllerTest.php
@@ -16,7 +16,7 @@
use CakeDC\Users\Model\Table\SocialAccountsTable;
use Cake\Core\Configure;
use Cake\Event\EventManager;
-use Cake\Network\Email\Email;
+use Cake\Mailer\Email;
use Cake\Network\Request;
use Cake\TestSuite\TestCase;
@@ -95,7 +95,7 @@ public function testValidateAccountHappy()
->method('redirect')
->with(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login']);
$this->Controller->validateAccount('Facebook', 'reference-1-1234', 'token-1234');
- $this->assertEquals('Account validated successfully', $this->Controller->request->session()->read('Flash.flash.message'));
+ $this->assertEquals('Account validated successfully', $this->Controller->request->session()->read('Flash.flash.0.message'));
}
/**
@@ -109,7 +109,7 @@ public function testValidateAccountInvalidToken()
->method('redirect')
->with(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login']);
$this->Controller->validateAccount('Facebook', 'reference-1-1234', 'token-not-found');
- $this->assertEquals('Invalid token and/or social account', $this->Controller->request->session()->read('Flash.flash.message'));
+ $this->assertEquals('Invalid token and/or social account', $this->Controller->request->session()->read('Flash.flash.0.message'));
}
/**
@@ -123,7 +123,7 @@ public function testValidateAccountAlreadyActive()
->method('redirect')
->with(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login']);
$this->Controller->validateAccount('Twitter', 'reference-1-1234', 'token-1234');
- $this->assertEquals('SocialAccount already active', $this->Controller->request->session()->read('Flash.flash.message'));
+ $this->assertEquals('SocialAccount already active', $this->Controller->request->session()->read('Flash.flash.0.message'));
}
/**
@@ -146,7 +146,7 @@ public function testResendValidationHappy()
->with(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login']);
$this->Controller->resendValidation('Facebook', 'reference-1-1234');
- $this->assertEquals('Email sent successfully', $this->Controller->request->session()->read('Flash.flash.message'));
+ $this->assertEquals('Email sent successfully', $this->Controller->request->session()->read('Flash.flash.0.message'));
}
/**
@@ -169,7 +169,7 @@ public function testResendValidationEmailError()
->with(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login']);
$this->Controller->resendValidation('Facebook', 'reference-1-1234');
- $this->assertEquals('Email could not be sent', $this->Controller->request->session()->read('Flash.flash.message'));
+ $this->assertEquals('Email could not be sent', $this->Controller->request->session()->read('Flash.flash.0.message'));
}
/**
@@ -183,7 +183,7 @@ public function testResendValidationInvalid()
->method('redirect')
->with(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login']);
$this->Controller->resendValidation('Facebook', 'reference-invalid');
- $this->assertEquals('Invalid account', $this->Controller->request->session()->read('Flash.flash.message'));
+ $this->assertEquals('Invalid account', $this->Controller->request->session()->read('Flash.flash.0.message'));
}
/**
@@ -197,6 +197,6 @@ public function testResendValidationAlreadyActive()
->method('redirect')
->with(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login']);
$this->Controller->validateAccount('Twitter', 'reference-1-1234', 'token-1234');
- $this->assertEquals('SocialAccount already active', $this->Controller->request->session()->read('Flash.flash.message'));
+ $this->assertEquals('SocialAccount already active', $this->Controller->request->session()->read('Flash.flash.0.message'));
}
}
diff --git a/tests/TestCase/Controller/Traits/BaseTraitTest.php b/tests/TestCase/Controller/Traits/BaseTraitTest.php
index 5905c7ee6..131d58aa5 100644
--- a/tests/TestCase/Controller/Traits/BaseTraitTest.php
+++ b/tests/TestCase/Controller/Traits/BaseTraitTest.php
@@ -12,7 +12,7 @@
namespace CakeDC\Users\Test\TestCase\Controller\Traits;
use Cake\Event\Event;
-use Cake\Network\Email\Email;
+use Cake\Mailer\Email;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
use PHPUnit_Framework_MockObject_RuntimeException;
diff --git a/tests/TestCase/Controller/Traits/RegisterTraitTest.php b/tests/TestCase/Controller/Traits/RegisterTraitTest.php
index 7d737f45b..0ea8e721e 100644
--- a/tests/TestCase/Controller/Traits/RegisterTraitTest.php
+++ b/tests/TestCase/Controller/Traits/RegisterTraitTest.php
@@ -14,7 +14,7 @@
use CakeDC\Users\Test\TestCase\Controller\Traits\BaseTraitTest;
use Cake\Core\Configure;
use Cake\Core\Plugin;
-use Cake\Network\Email\Email;
+use Cake\Mailer\Email;
use Cake\ORM\TableRegistry;
class RegisterTraitTest extends BaseTraitTest
diff --git a/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php b/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php
index 85defd0f8..f782e0d0c 100644
--- a/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php
+++ b/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php
@@ -13,7 +13,7 @@
use CakeDC\Users\Exception\UserAlreadyActiveException;
use CakeDC\Users\Model\Table\UsersTable;
-use Cake\Network\Email\Email;
+use Cake\Mailer\Email;
use Cake\ORM\TableRegistry;
use Cake\Routing\Router;
use Cake\TestSuite\TestCase;
diff --git a/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php b/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php
index 79df58c67..5148525ce 100644
--- a/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php
+++ b/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php
@@ -12,7 +12,7 @@
namespace CakeDC\Users\Test\TestCase\Model\Behavior;
-use Cake\Network\Email\Email;
+use Cake\Mailer\Email;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
use InvalidArgumentException;
diff --git a/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php b/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php
index d341d6927..2c0344bb7 100644
--- a/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php
+++ b/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php
@@ -13,7 +13,7 @@
use CakeDC\Users\Model\Table\SocialAccountsTable;
use Cake\Event\Event;
-use Cake\Network\Email\Email;
+use Cake\Mailer\Email;
use Cake\ORM\TableRegistry;
use Cake\Routing\Router;
use Cake\TestSuite\TestCase;
diff --git a/tests/TestCase/Model/Table/SocialAccountsTableTest.php b/tests/TestCase/Model/Table/SocialAccountsTableTest.php
index 40e99c912..e57156cec 100644
--- a/tests/TestCase/Model/Table/SocialAccountsTableTest.php
+++ b/tests/TestCase/Model/Table/SocialAccountsTableTest.php
@@ -14,7 +14,7 @@
use CakeDC\Users\Model\Table\SocialAccountsTable;
use CakeDC\Users\Model\Table\UsersTable;
use Cake\Event\Event;
-use Cake\Network\Email\Email;
+use Cake\Mailer\Email;
use Cake\ORM\TableRegistry;
use Cake\Routing\Router;
use Cake\TestSuite\TestCase;
diff --git a/tests/TestCase/Model/Table/UsersTableTest.php b/tests/TestCase/Model/Table/UsersTableTest.php
index 05011fbf7..ecafc1817 100644
--- a/tests/TestCase/Model/Table/UsersTableTest.php
+++ b/tests/TestCase/Model/Table/UsersTableTest.php
@@ -16,7 +16,7 @@
use CakeDC\Users\Exception\UserNotFoundException;
use CakeDC\Users\Model\Table\SocialAccountsTable;
use Cake\Core\Plugin;
-use Cake\Network\Email\Email;
+use Cake\Mailer\Email;
use Cake\ORM\TableRegistry;
use Cake\Routing\Router;
use Cake\TestSuite\TestCase;
From 257efa5f75298237a8129a8dc838057e0eca988d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Wed, 23 Sep 2015 00:41:24 +0100
Subject: [PATCH 0202/1397] fix docs for 3.1
---
Docs/Documentation/Installation.md | 2 +-
Docs/Home.md | 2 +-
README.md | 10 +++++-----
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/Docs/Documentation/Installation.md b/Docs/Documentation/Installation.md
index c6c16960f..cf93f6d14 100644
--- a/Docs/Documentation/Installation.md
+++ b/Docs/Documentation/Installation.md
@@ -5,7 +5,7 @@ Composer
------
```
-composer require cakedc/users:3.0.*
+composer require cakedc/users:3.1.*
```
if you want to use social login features...
diff --git a/Docs/Home.md b/Docs/Home.md
index 293762fda..4250dea39 100644
--- a/Docs/Home.md
+++ b/Docs/Home.md
@@ -13,7 +13,7 @@ That it works out of the box doesn't mean it is thought to be used exactly like
Requirements
------------
-* CakePHP 3.0.*
+* CakePHP 3.1.*
* PHP 5.4.16+
Documentation
diff --git a/README.md b/README.md
index 37482c153..23fbad85f 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,11 @@
CakeDC Users Plugin
===================
-[](http://travis-ci.org/CakeDC/users)
+[](http://travis-ci.org/CakeDC/users)
[](https://packagist.org/packages/CakeDC/users)
[](https://packagist.org/packages/CakeDC/users)
-IMPORTANT: 3.0.x version is BETA status now, we are still improving and testing it.
+IMPORTANT: 3.1.x version is BETA status now, we are still improving and testing it.
The **Users** plugin is back!
@@ -34,7 +34,7 @@ Another decision made was limiting the plugin dependencies on other packages as
Requirements
------------
-* CakePHP 3.0.*
+* CakePHP 3.1.*
* PHP 5.4.16+
Documentation
@@ -45,11 +45,11 @@ For documentation, as well as tutorials, see the [Docs](Docs/Home.md) directory
Roadmap
------
-* 3.0.2
+* 3.1.2
* Add Google authentication
* Add Instagram authentication
* Improve unit test coverage
-* YOU ARE HERE > 3.0.0 Migration to CakePHP 3.0
+* YOU ARE HERE > 3.1.0 Migration to CakePHP 3.0
* Unit test coverage improvements
* Refactor UsersTable to Behavior
* Add google authentication
From 6a9cba6e4d52911ca5847d41dff22188b3798b58 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20M=2E=20Gonz=C3=A1lez=20Mart=C3=ADn?=
Date: Wed, 23 Sep 2015 13:21:43 +0100
Subject: [PATCH 0203/1397] Update .semver
---
.semver | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.semver b/.semver
index c8cec4bb8..daa667f3f 100644
--- a/.semver
+++ b/.semver
@@ -1,5 +1,5 @@
---
-:major: 2
+:major: 3
:minor: 1
-:patch: 1
+:patch: 0
:special: ''
From 3c52743074cdd666c40e4e6312c6c8d294122dd2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20M=2E=20Gonz=C3=A1lez=20Mart=C3=ADn?=
Date: Wed, 23 Sep 2015 23:00:57 +0100
Subject: [PATCH 0204/1397] Update .semver
---
.semver | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.semver b/.semver
index c8cec4bb8..d834cab69 100644
--- a/.semver
+++ b/.semver
@@ -1,5 +1,5 @@
---
:major: 2
:minor: 1
-:patch: 1
+:patch: 2
:special: ''
From 3af374571db877e2ee1f8eff978f0a58b8458917 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20M=2E=20Gonz=C3=A1lez=20Mart=C3=ADn?=
Date: Wed, 23 Sep 2015 23:13:25 +0100
Subject: [PATCH 0205/1397] Update README.md
---
README.md | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 7ca37d52c..fc81262aa 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,14 @@ CakeDC Users Plugin
[](https://packagist.org/packages/CakeDC/users)
[](https://packagist.org/packages/CakeDC/users)
-**IMPORTANT: 3.x version is ALPHA status now and you can check it out from [CakeDC Users Plugin for CakePHP 3.x](https://github.com/cakedc/users/tree/3.x)!, we are constantly improving and testing it now.**
+Versions and branches
+---------------------
+
+| CakePHP | CakeDC Users Plugin | Tag | Notes |
+| :-------------: | :------------------------: | :--: | :---- |
+| 2.x | [master](https://github.com/cakedc/users/tree/master) | 2.1.2 | Note CakePHP 2.7 is currently not supported, we are working on it now |
+| 3.0 | [3.0.x](https://github.com/cakedc/users/tree/3.0.x) | 3.0.0 | stability is beta, but pretty stable now |
+| 3.1 | [3.1.x](https://github.com/cakedc/users/tree/3.1.x) | 3.1.0 | stability is beta, but pretty stable now |
The **Users** plugin is for allowing users to register and login manage their profile. It also allows admins to manage the users.
From 0ddd715a61292d5a29b11962ba5026ff236d8f6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20M=2E=20Gonz=C3=A1lez=20Mart=C3=ADn?=
Date: Wed, 23 Sep 2015 23:17:42 +0100
Subject: [PATCH 0206/1397] Update README.md
---
README.md | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/README.md b/README.md
index 23fbad85f..72a95e3b7 100644
--- a/README.md
+++ b/README.md
@@ -7,6 +7,15 @@ CakeDC Users Plugin
IMPORTANT: 3.1.x version is BETA status now, we are still improving and testing it.
+Versions and branches
+---------------------
+
+| CakePHP | CakeDC Users Plugin | Tag | Notes |
+| :-------------: | :------------------------: | :--: | :---- |
+| 2.x | [master](https://github.com/cakedc/users/tree/master) | 2.1.2 | Note CakePHP 2.7 is currently not supported, we are working on it now |
+| 3.0 | [3.0.x](https://github.com/cakedc/users/tree/3.0.x) | 3.0.0 | stability is beta, but pretty stable now |
+| 3.1 | [3.1.x](https://github.com/cakedc/users/tree/3.1.x) | 3.1.0 | stability is beta, but pretty stable now |
+
The **Users** plugin is back!
It covers the following features:
From b8c71a97037c76d2a673d99271cbb6459a735de2 Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Thu, 24 Sep 2015 00:01:15 +0000
Subject: [PATCH 0207/1397] fix validation to notBlank per 2.7 deprecation of
notEmpty
---
Model/User.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Model/User.php b/Model/User.php
index 67fa27003..a4b2e2e22 100644
--- a/Model/User.php
+++ b/Model/User.php
@@ -86,7 +86,7 @@ class User extends UsersAppModel {
public $validate = array(
'username' => array(
'required' => array(
- 'rule' => array('notEmpty'),
+ 'rule' => array('notBlank'),
'required' => true, 'allowEmpty' => false,
'message' => 'Please enter a username.'
),
@@ -120,7 +120,7 @@ class User extends UsersAppModel {
'message' => 'The password must have at least 6 characters.'
),
'required' => array(
- 'rule' => 'notEmpty',
+ 'rule' => 'notBlank',
'message' => 'Please enter a password.'
)
),
From 6f07c11742ee4b356376e9efbce3da4acebc0ab7 Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Thu, 24 Sep 2015 00:10:42 +0000
Subject: [PATCH 0208/1397] fix notBlank to be backward compatible
---
Model/User.php | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/Model/User.php b/Model/User.php
index a4b2e2e22..cb8c2456c 100644
--- a/Model/User.php
+++ b/Model/User.php
@@ -86,8 +86,9 @@ class User extends UsersAppModel {
public $validate = array(
'username' => array(
'required' => array(
- 'rule' => array('notBlank'),
- 'required' => true, 'allowEmpty' => false,
+ 'rule' => array('minLength', 1),
+ 'required' => true,
+ 'allowEmpty' => false,
'message' => 'Please enter a username.'
),
'alpha' => array(
@@ -120,7 +121,7 @@ class User extends UsersAppModel {
'message' => 'The password must have at least 6 characters.'
),
'required' => array(
- 'rule' => 'notBlank',
+ 'rule' => array('minLength', 1),
'message' => 'Please enter a password.'
)
),
From 5b0f7671f14fe7d37c1428b53c539a6d6ff179ae Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Thu, 24 Sep 2015 00:33:36 +0000
Subject: [PATCH 0209/1397] add test and checking notEmpty backward compatible
---
Model/User.php | 6 +-----
Test/Case/Model/UserTest.php | 22 ++++++++++++++++++++++
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/Model/User.php b/Model/User.php
index cb8c2456c..a73ab8c56 100644
--- a/Model/User.php
+++ b/Model/User.php
@@ -86,7 +86,7 @@ class User extends UsersAppModel {
public $validate = array(
'username' => array(
'required' => array(
- 'rule' => array('minLength', 1),
+ 'rule' => array('custom', '/.+/'),
'required' => true,
'allowEmpty' => false,
'message' => 'Please enter a username.'
@@ -120,10 +120,6 @@ class User extends UsersAppModel {
'rule' => array('minLength', '6'),
'message' => 'The password must have at least 6 characters.'
),
- 'required' => array(
- 'rule' => array('minLength', 1),
- 'message' => 'Please enter a password.'
- )
),
'temppassword' => array(
'rule' => 'confirmPassword',
diff --git a/Test/Case/Model/UserTest.php b/Test/Case/Model/UserTest.php
index ac5750bd7..1cb06c46c 100755
--- a/Test/Case/Model/UserTest.php
+++ b/Test/Case/Model/UserTest.php
@@ -256,6 +256,28 @@ public function testRegister() {
$this->assertEquals(array_keys($this->User->invalidFields()), array(
'password'));
+ $postData = array('User' => array(
+ 'username' => ' ',
+ 'email' => 'test@test.com',
+ 'password' => '123456',
+ 'temppassword' => '123456',
+ 'tos' => 1));
+ $result = $this->User->register($postData);
+ $this->assertFalse($result);
+ $this->assertEquals(array_keys($this->User->invalidFields()), array(
+ 'username'));
+
+ $postData = array('User' => array(
+ 'username' => ' ',
+ 'email' => 'test@test.com',
+ 'password' => '123456',
+ 'temppassword' => '123456',
+ 'tos' => 1));
+ $result = $this->User->register($postData);
+ $this->assertFalse($result);
+ $this->assertEquals(array_keys($this->User->invalidFields()), array(
+ 'username'));
+
$postData = array('User' => array(
'username' => 'imanewuser',
'email' => 'foo@bar.com',
From e8e2b65c96e552d46066229c72f754d43ae2d7dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20M=2E=20Gonz=C3=A1lez=20Mart=C3=ADn?=
Date: Thu, 24 Sep 2015 01:49:11 +0100
Subject: [PATCH 0210/1397] Update .semver
---
.semver | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.semver b/.semver
index d834cab69..f7db3a29f 100644
--- a/.semver
+++ b/.semver
@@ -1,5 +1,5 @@
---
:major: 2
:minor: 1
-:patch: 2
+:patch: 3
:special: ''
From 4d775c00f8f3b02f575bf4cbe6e3340f2a1fed5d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20M=2E=20Gonz=C3=A1lez=20Mart=C3=ADn?=
Date: Thu, 24 Sep 2015 01:52:26 +0100
Subject: [PATCH 0211/1397] Update CHANGELOG.md
---
CHANGELOG.md | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7346d789c..85b29decc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,21 @@
Changelog
=========
+Release 2.1.3
+-------------
+
+https://github.com/CakeDC/users/tree/2.1.3
+
+* Fixed unit tests for compatibility with CakePHP 2.7
+
+Release 2.1.2
+-------------
+
+https://github.com/CakeDC/users/tree/2.1.2
+
+* Minor improvements
+* New translations (german and portuguese)
+
Release 2.1.1
-------------
@@ -43,4 +58,4 @@ https://github.com/CakeDC/users/tree/2.1.0
* [f93ce41](https://github.com/CakeDC/users/commit/f93ce41) Minor improvement to the flash message that shows the username in the UsersController.php
* [b6ee0ad](https://github.com/CakeDC/users/commit/b6ee0ad) Refs https://github.com/CakeDC/users/issues/145, fixing the links in the sidebar when not used from the plugin
* [720ebb5](https://github.com/CakeDC/users/commit/720ebb5) Refs https://github.com/CakeDC/users/pull/146
- * [46d6321](https://github.com/CakeDC/users/commit/46d6321) Renamed locale fre => fra, since 2.3 CakePHP uses ISO standard.
\ No newline at end of file
+ * [46d6321](https://github.com/CakeDC/users/commit/46d6321) Renamed locale fre => fra, since 2.3 CakePHP uses ISO standard.
From 811d810476022c27e42ab95aee6973370b736a7e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20M=2E=20Gonz=C3=A1lez=20Mart=C3=ADn?=
Date: Thu, 24 Sep 2015 01:55:04 +0100
Subject: [PATCH 0212/1397] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index fc81262aa..6b2217e3c 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ Versions and branches
| CakePHP | CakeDC Users Plugin | Tag | Notes |
| :-------------: | :------------------------: | :--: | :---- |
-| 2.x | [master](https://github.com/cakedc/users/tree/master) | 2.1.2 | Note CakePHP 2.7 is currently not supported, we are working on it now |
+| 2.x | [master](https://github.com/cakedc/users/tree/master) | 2.1.3 | Note CakePHP 2.7 is currently not supported, we are working on it now |
| 3.0 | [3.0.x](https://github.com/cakedc/users/tree/3.0.x) | 3.0.0 | stability is beta, but pretty stable now |
| 3.1 | [3.1.x](https://github.com/cakedc/users/tree/3.1.x) | 3.1.0 | stability is beta, but pretty stable now |
From 4174e9369ae156a875c6a092ca1448c65b57120e Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Sat, 26 Sep 2015 02:08:30 +0000
Subject: [PATCH 0213/1397] fix migration to use boolean type correctly in
Postgresql
---
config/Migrations/20150513201111_initial.php | 11 ++---
tests/Fixture/SocialAccountsFixture.php | 12 +++---
tests/Fixture/UsersFixture.php | 44 ++++++++++----------
3 files changed, 32 insertions(+), 35 deletions(-)
diff --git a/config/Migrations/20150513201111_initial.php b/config/Migrations/20150513201111_initial.php
index b55ab65cf..d1e11e0ec 100644
--- a/config/Migrations/20150513201111_initial.php
+++ b/config/Migrations/20150513201111_initial.php
@@ -73,8 +73,7 @@ public function up()
'null' => true,
])
->addColumn('active', 'boolean', [
- 'default' => 1,
- 'limit' => 1,
+ 'default' => true,
'null' => false,
])
->addColumn('data', 'text', [
@@ -151,13 +150,11 @@ public function up()
'null' => true,
])
->addColumn('active', 'boolean', [
- 'default' => 0,
- 'limit' => 1,
+ 'default' => false,
'null' => false,
])
- ->addColumn('is_superuser', 'integer', [
- 'default' => 0,
- 'limit' => 1,
+ ->addColumn('is_superuser', 'boolean', [
+ 'default' => false,
'null' => false,
])
->addColumn('role', 'string', [
diff --git a/tests/Fixture/SocialAccountsFixture.php b/tests/Fixture/SocialAccountsFixture.php
index 6f3d9dda8..7e014fa58 100644
--- a/tests/Fixture/SocialAccountsFixture.php
+++ b/tests/Fixture/SocialAccountsFixture.php
@@ -27,7 +27,7 @@ class SocialAccountsFixture extends TestFixture
'token' => ['type' => 'string', 'length' => 500, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null],
'token_secret' => ['type' => 'string', 'length' => 500, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null],
'token_expires' => ['type' => 'datetime', 'length' => null, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null],
- 'active' => ['type' => 'boolean', 'length' => null, 'null' => false, 'default' => '1', 'comment' => '', 'precision' => null],
+ 'active' => ['type' => 'boolean', 'length' => null, 'null' => false, 'default' => true, 'comment' => '', 'precision' => null],
'data' => ['type' => 'text', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null],
'created' => ['type' => 'datetime', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null],
'modified' => ['type' => 'datetime', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null],
@@ -58,7 +58,7 @@ class SocialAccountsFixture extends TestFixture
'token' => 'token-1234',
'token_secret' => 'Lorem ipsum dolor sit amet',
'token_expires' => '2015-05-22 21:52:44',
- 'active' => 0,
+ 'active' => false,
'data' => '',
'created' => '2015-05-22 21:52:44',
'modified' => '2015-05-22 21:52:44'
@@ -74,7 +74,7 @@ class SocialAccountsFixture extends TestFixture
'token' => 'token-1234',
'token_secret' => 'Lorem ipsum dolor sit amet',
'token_expires' => '2015-05-22 21:52:44',
- 'active' => 1,
+ 'active' => true,
'data' => '',
'created' => '2015-05-22 21:52:44',
'modified' => '2015-05-22 21:52:44'
@@ -90,7 +90,7 @@ class SocialAccountsFixture extends TestFixture
'token' => 'token-reference-2-1',
'token_secret' => 'Lorem ipsum dolor sit amet',
'token_expires' => '2015-05-22 21:52:44',
- 'active' => 1,
+ 'active' => true,
'data' => '',
'created' => '2015-05-22 21:52:44',
'modified' => '2015-05-22 21:52:44'
@@ -106,7 +106,7 @@ class SocialAccountsFixture extends TestFixture
'token' => 'token-reference-2-2',
'token_secret' => 'Lorem ipsum dolor sit amet',
'token_expires' => '2015-05-22 21:52:44',
- 'active' => 0,
+ 'active' => false,
'data' => '',
'created' => '2015-05-22 21:52:44',
'modified' => '2015-05-22 21:52:44'
@@ -122,7 +122,7 @@ class SocialAccountsFixture extends TestFixture
'token' => 'token-reference-2-2',
'token_secret' => 'Lorem ipsum dolor sit amet',
'token_expires' => '2015-05-22 21:52:44',
- 'active' => 0,
+ 'active' => false,
'data' => '',
'created' => '2015-05-22 21:52:44',
'modified' => '2015-05-22 21:52:44'
diff --git a/tests/Fixture/UsersFixture.php b/tests/Fixture/UsersFixture.php
index 8ba1b1d9a..4521f5270 100644
--- a/tests/Fixture/UsersFixture.php
+++ b/tests/Fixture/UsersFixture.php
@@ -38,8 +38,8 @@ class UsersFixture extends TestFixture
'api_token' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null],
'activation_date' => ['type' => 'datetime', 'length' => null, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null],
'tos_date' => ['type' => 'datetime', 'length' => null, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null],
- 'active' => ['type' => 'boolean', 'length' => null, 'null' => false, 'default' => '0', 'comment' => '', 'precision' => null],
- 'is_superuser' => ['type' => 'integer', 'length' => 1, 'unsigned' => false, 'null' => false, 'default' => '0', 'comment' => '', 'precision' => null, 'autoIncrement' => null],
+ 'active' => ['type' => 'boolean', 'length' => null, 'null' => false, 'default' => true, 'comment' => '', 'precision' => null],
+ 'is_superuser' => ['type' => 'boolean', 'length' => null, 'unsigned' => false, 'null' => false, 'default' => false, 'comment' => '', 'precision' => null, 'autoIncrement' => null],
'role' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => 'user', 'comment' => '', 'precision' => null, 'fixed' => null],
'created' => ['type' => 'datetime', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null],
'modified' => ['type' => 'datetime', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null],
@@ -71,8 +71,8 @@ class UsersFixture extends TestFixture
'api_token' => 'yyy',
'activation_date' => '2015-06-24 17:33:54',
'tos_date' => '2015-06-24 17:33:54',
- 'active' => 0,
- 'is_superuser' => 1,
+ 'active' => false,
+ 'is_superuser' => true,
'role' => 'admin',
'created' => '2015-06-24 17:33:54',
'modified' => '2015-06-24 17:33:54'
@@ -89,8 +89,8 @@ class UsersFixture extends TestFixture
'api_token' => 'xxx',
'activation_date' => '2015-06-24 17:33:54',
'tos_date' => '2015-06-24 17:33:54',
- 'active' => 1,
- 'is_superuser' => 1,
+ 'active' => true,
+ 'is_superuser' => true,
'role' => 'admin',
'created' => '2015-06-24 17:33:54',
'modified' => '2015-06-24 17:33:54'
@@ -107,8 +107,8 @@ class UsersFixture extends TestFixture
'api_token' => 'xxx',
'activation_date' => '2015-06-24 17:33:54',
'tos_date' => '2015-06-24 17:33:54',
- 'active' => 0,
- 'is_superuser' => 1,
+ 'active' => false,
+ 'is_superuser' => true,
'role' => 'admin',
'created' => '2015-06-24 17:33:54',
'modified' => '2015-06-24 17:33:54'
@@ -125,8 +125,8 @@ class UsersFixture extends TestFixture
'api_token' => 'Lorem ipsum dolor sit amet',
'activation_date' => '2015-06-24 17:33:54',
'tos_date' => '2015-06-24 17:33:54',
- 'active' => 1,
- 'is_superuser' => 4,
+ 'active' => true,
+ 'is_superuser' => false,
'role' => 'Lorem ipsum dolor sit amet',
'created' => '2015-06-24 17:33:54',
'modified' => '2015-06-24 17:33:54'
@@ -143,8 +143,8 @@ class UsersFixture extends TestFixture
'api_token' => '',
'activation_date' => '2015-06-24 17:33:54',
'tos_date' => '2015-06-24 17:33:54',
- 'active' => 0,
- 'is_superuser' => 0,
+ 'active' => true,
+ 'is_superuser' => false,
'role' => 'user',
'created' => '2015-06-24 17:33:54',
'modified' => '2015-06-24 17:33:54'
@@ -161,8 +161,8 @@ class UsersFixture extends TestFixture
'api_token' => 'Lorem ipsum dolor sit amet',
'activation_date' => '2015-06-24 17:33:54',
'tos_date' => '2015-06-24 17:33:54',
- 'active' => 1,
- 'is_superuser' => 6,
+ 'active' => true,
+ 'is_superuser' => false,
'role' => 'Lorem ipsum dolor sit amet',
'created' => '2015-06-24 17:33:54',
'modified' => '2015-06-24 17:33:54'
@@ -179,8 +179,8 @@ class UsersFixture extends TestFixture
'api_token' => 'Lorem ipsum dolor sit amet',
'activation_date' => '2015-06-24 17:33:54',
'tos_date' => '2015-06-24 17:33:54',
- 'active' => 1,
- 'is_superuser' => 7,
+ 'active' => true,
+ 'is_superuser' => false,
'role' => 'Lorem ipsum dolor sit amet',
'created' => '2015-06-24 17:33:54',
'modified' => '2015-06-24 17:33:54'
@@ -197,8 +197,8 @@ class UsersFixture extends TestFixture
'api_token' => 'Lorem ipsum dolor sit amet',
'activation_date' => '2015-06-24 17:33:54',
'tos_date' => '2015-06-24 17:33:54',
- 'active' => 1,
- 'is_superuser' => 8,
+ 'active' => true,
+ 'is_superuser' => false,
'role' => 'Lorem ipsum dolor sit amet',
'created' => '2015-06-24 17:33:54',
'modified' => '2015-06-24 17:33:54'
@@ -215,8 +215,8 @@ class UsersFixture extends TestFixture
'api_token' => 'Lorem ipsum dolor sit amet',
'activation_date' => '2015-06-24 17:33:54',
'tos_date' => '2015-06-24 17:33:54',
- 'active' => 1,
- 'is_superuser' => 9,
+ 'active' => true,
+ 'is_superuser' => false,
'role' => 'Lorem ipsum dolor sit amet',
'created' => '2015-06-24 17:33:54',
'modified' => '2015-06-24 17:33:54'
@@ -233,8 +233,8 @@ class UsersFixture extends TestFixture
'api_token' => 'Lorem ipsum dolor sit amet',
'activation_date' => '2015-06-24 17:33:54',
'tos_date' => '2015-06-24 17:33:54',
- 'active' => 1,
- 'is_superuser' => 10,
+ 'active' => true,
+ 'is_superuser' => false,
'role' => 'Lorem ipsum dolor sit amet',
'created' => '2015-06-24 17:33:54',
'modified' => '2015-06-24 17:33:54'
From 146d781456572cb2c8442c17a0c0c6b7e98c4c99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20M=2E=20Gonz=C3=A1lez=20Mart=C3=ADn?=
Date: Fri, 2 Oct 2015 13:47:21 +0100
Subject: [PATCH 0214/1397] Update Installation.md
---
Docs/Documentation/Installation.md | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/Docs/Documentation/Installation.md b/Docs/Documentation/Installation.md
index cf93f6d14..db8527cff 100644
--- a/Docs/Documentation/Installation.md
+++ b/Docs/Documentation/Installation.md
@@ -16,6 +16,18 @@ composer require opauth/facebook:1.0.x-dev
composer require opauth/twitter:1.0.x-dev
```
+IMPORTANT: We have a fork adding some fixes to the facebook strategy, please add to your composer.json file:
+
+```
+ "repositories":
+ [
+ {
+ "type": "vcs",
+ "url": "https://github.com/CakeDC/facebook.git"
+ }
+ ],
+```
+
Creating Required Tables
------------------------
If you want to use the Users tables to store your users and social accounts:
From a549b81cfd369467b99cec35d9714354c6ff158a Mon Sep 17 00:00:00 2001
From: Yelitza Parra
Date: Mon, 5 Oct 2015 10:33:22 -0430
Subject: [PATCH 0215/1397] Emails refactoring based on the new Mailer features
in cakephp 3.1
---
src/Email/EmailSender.php | 83 +++++++++
src/Mailer/UserMailer.php | 88 ++++++++++
src/Model/Behavior/Behavior.php | 42 -----
src/Model/Behavior/PasswordBehavior.php | 36 ++--
src/Model/Behavior/RegisterBehavior.php | 4 +-
src/Model/Behavior/SocialAccountBehavior.php | 17 +-
tests/TestCase/Email/EmailSenderTest.php | 159 ++++++++++++++++++
.../Model/Behavior/PasswordBehaviorTest.php | 11 +-
.../Behavior/SocialAccountBehaviorTest.php | 16 +-
9 files changed, 360 insertions(+), 96 deletions(-)
create mode 100644 src/Email/EmailSender.php
create mode 100644 src/Mailer/UserMailer.php
create mode 100644 tests/TestCase/Email/EmailSenderTest.php
diff --git a/src/Email/EmailSender.php b/src/Email/EmailSender.php
new file mode 100644
index 000000000..3f75f6765
--- /dev/null
+++ b/src/Email/EmailSender.php
@@ -0,0 +1,83 @@
+getMailer('CakeDC/Users.User',
+ $this->_getEmailInstance($email))->send('validation', [$user, __d('Users', 'Your account validation link')]
+ );
+ }
+
+ /**
+ * Send the reset password email
+ *
+ * @param EntityInterface $user User entity
+ * @param Email $email instance, if null the default email configuration with the
+ * @param string $template email template
+ * Users.validation template will be used, so set a ->template() if you pass an Email
+ * instance
+ * @return array email send result
+ */
+ public function sendResetPasswordEmail(EntityInterface $user, Email $email = null, $template = 'CakeDC/Users.reset_password')
+ {
+ $this->getMailer('CakeDC/Users.User',
+ $this->_getEmailInstance($email))->send('resetPassword', [$user, $template]
+ );
+ }
+
+ /**
+ * Send social validation email to the user
+ *
+ * @param EntityInterface $socialAccount social account
+ * @param EntityInterface $user user
+ * @param Email $email Email instance or null to use 'default' configuration
+ * @return mixed
+ */
+ public function sendSocialValidationEmail(EntityInterface $socialAccount, EntityInterface $user, Email $email = null)
+ {
+ if (empty($email)) {
+ $template = 'CakeDC/Users.social_account_validation';
+ } else {
+ $template = $email->template()['template'];
+ }
+ $this->getMailer('CakeDC/Users.User',
+ $this->_getEmailInstance($email))->send('socialAccountValidation', [$user, $socialAccount, $template]
+ );
+ }
+
+ /**
+ * Get or initialize the email instance. Used for mocking.
+ *
+ * @param Email $email if email provided, we'll use the instance instead of creating a new one
+ * @return Email
+ */
+ protected function _getEmailInstance(Email $email = null)
+ {
+ if ($email === null) {
+ $email = new Email('default');
+ $email->emailFormat('both');
+ }
+ return $email;
+ }
+}
\ No newline at end of file
diff --git a/src/Mailer/UserMailer.php b/src/Mailer/UserMailer.php
new file mode 100644
index 000000000..519f094c8
--- /dev/null
+++ b/src/Mailer/UserMailer.php
@@ -0,0 +1,88 @@
+to($user['email'])
+ ->subject($firstName . $subject)
+ ->viewVars($user->toArray())
+ ->template('CakeDC/Users.validation');
+
+ if (!empty($template)) {
+ $this->template($template);
+ }
+
+ }
+
+ /**
+ * Send the reset password email to the user
+ *
+ * @param EntityInterface $user User entity
+ * @param string $template string, note the first_name of the user will be prepended if exists
+ *
+ * @return array email send result
+ */
+ protected function resetPassword(EntityInterface $user, $template = 'CakeDC/Users.reset_password')
+ {
+ $firstName = isset($user['first_name'])? $user['first_name'] . ', ' : '';
+ $subject = __d('Users', '{0}Your reset password link', $firstName);
+
+ $this
+ ->to($user['email'])
+ ->template($template)
+ ->subject($subject)
+ ->viewVars($user->toArray());
+ }
+
+ /**
+ * Send account validation email to the user
+ *
+ * @param EntityInterface $user User entity
+ * @param EntityInterface $socialAccount SocialAccount entity
+ *
+ * @return array email send result
+ */
+ protected function socialAccountValidation(EntityInterface $user, EntityInterface $socialAccount)
+ {
+ $firstName = isset($user['first_name'])? $user['first_name'] . ', ' : '';
+ //note: we control the space after the username in the previous line
+ $subject = __d('Users', '{0}Your social account validation link', $firstName);
+ $this
+ ->to($user['email'])
+ ->subject($subject)
+ ->viewVars(compact('user', 'socialAccount'));
+ }
+}
+
diff --git a/src/Model/Behavior/Behavior.php b/src/Model/Behavior/Behavior.php
index d0307d980..75752974f 100644
--- a/src/Model/Behavior/Behavior.php
+++ b/src/Model/Behavior/Behavior.php
@@ -13,7 +13,6 @@
use Cake\Datasource\EntityInterface;
use Cake\I18n\Time;
-use Cake\Mailer\Email;
use Cake\ORM\Behavior as BaseBehavior;
/**
@@ -21,47 +20,6 @@
*/
class Behavior extends BaseBehavior
{
-
- /**
- * Send the templated email to the user
- *
- * @param EntityInterface $user User entity
- * @param string $subject Subject, note the first_name of the user will be prepended if exists
- * @param Email $email instance, if null the default email configuration with the
- * Users.validation template will be used, so set a ->template() if you pass an Email
- * instance
- *
- * @return array email send result
- */
- protected function _sendEmail(EntityInterface $user, $subject, Email $email = null)
- {
- $firstName = isset($user['first_name'])? $user['first_name'] . ', ' : '';
- $emailInstance = $this->_getEmailInstance($email)
- ->to($user['email'])
- ->subject($firstName . $subject)
- ->viewVars($user->toArray());
- if (empty($email)) {
- $emailInstance->template('CakeDC/Users.validation');
- }
- return $emailInstance->send();
- }
-
- /**
- * Get or initialize the email instance. Used for mocking.
- *
- * @param Email $email if email provided, we'll use the instance instead of creating a new one
- * @return Email
- */
- protected function _getEmailInstance(Email $email = null)
- {
- if ($email === null) {
- $email = new Email('default');
- $email->emailFormat('both');
- }
-
- return $email;
- }
-
/**
* DRY for update active and token based on validateEmail flag
*
diff --git a/src/Model/Behavior/PasswordBehavior.php b/src/Model/Behavior/PasswordBehavior.php
index fc87c150d..6f5d62346 100644
--- a/src/Model/Behavior/PasswordBehavior.php
+++ b/src/Model/Behavior/PasswordBehavior.php
@@ -11,6 +11,7 @@
namespace CakeDC\Users\Model\Behavior;
+use CakeDC\Users\Email\EmailSender;
use CakeDC\Users\Exception\UserAlreadyActiveException;
use CakeDC\Users\Exception\UserNotFoundException;
use CakeDC\Users\Exception\WrongPasswordException;
@@ -25,6 +26,17 @@
*/
class PasswordBehavior extends Behavior
{
+ /**
+ * Constructor hook method.
+ *
+ * @param array $config The configuration settings provided to this behavior.
+ * @return void
+ */
+ public function initialize(array $config)
+ {
+ parent::initialize($config);
+ $this->Email = new EmailSender();
+ }
/**
* Resets user token
*
@@ -63,7 +75,7 @@ public function resetToken($reference, array $options = [])
$saveResult = $this->_table->save($user);
$template = !empty($options['emailTemplate']) ? $options['emailTemplate'] : 'CakeDC/Users.reset_password';
if (Hash::get($options, 'sendEmail')) {
- $this->sendResetPasswordEmail($saveResult, null, $template);
+ $this->Email->sendResetPasswordEmail($saveResult, null, $template);
}
return $saveResult;
}
@@ -79,28 +91,6 @@ protected function _getUser($reference)
return $this->_table->findAllByUsernameOrEmail($reference, $reference)->first();
}
- /**
- * Send the reset password email
- *
- * @param EntityInterface $user User entity
- * @param Email $email instance, if null the default email configuration with the
- * @param string $template email template
- * Users.validation template will be used, so set a ->template() if you pass an Email
- * instance
- * @return array email send result
- */
- public function sendResetPasswordEmail(EntityInterface $user, Email $email = null, $template = 'CakeDC/Users.reset_password')
- {
- $firstName = isset($user['first_name'])? $user['first_name'] . ', ' : '';
- $subject = __d('Users', '{0}Your reset password link', $firstName);
- return $this->_getEmailInstance($email)
- ->template($template)
- ->to($user['email'])
- ->subject($subject)
- ->viewVars($user->toArray())
- ->send();
- }
-
/**
* Change password method
*
diff --git a/src/Model/Behavior/RegisterBehavior.php b/src/Model/Behavior/RegisterBehavior.php
index ab95edc72..d64c17d25 100644
--- a/src/Model/Behavior/RegisterBehavior.php
+++ b/src/Model/Behavior/RegisterBehavior.php
@@ -11,6 +11,7 @@
namespace CakeDC\Users\Model\Behavior;
+use CakeDC\Users\Email\EmailSender;
use CakeDC\Users\Exception\TokenExpiredException;
use CakeDC\Users\Exception\UserAlreadyActiveException;
use CakeDC\Users\Exception\UserNotFoundException;
@@ -40,6 +41,7 @@ public function initialize(array $config)
parent::initialize($config);
$this->validateEmail = (bool)Configure::read('Users.Email.validate');
$this->useTos = (bool)Configure::read('Users.Tos.required');
+ $this->Email = new EmailSender();
}
/**
@@ -63,7 +65,7 @@ public function register($user, $data, $options)
$this->_table->isValidateEmail = $validateEmail;
$userSaved = $this->_table->save($user);
if ($userSaved && $validateEmail) {
- $this->_sendEmail($user, __d('Users', 'Your account validation link'), $emailClass);
+ $this->Email->sendValidationEmail($user, $emailClass);
}
return $userSaved;
}
diff --git a/src/Model/Behavior/SocialAccountBehavior.php b/src/Model/Behavior/SocialAccountBehavior.php
index 8b37502b2..1c8cf8b7d 100644
--- a/src/Model/Behavior/SocialAccountBehavior.php
+++ b/src/Model/Behavior/SocialAccountBehavior.php
@@ -12,6 +12,7 @@
namespace CakeDC\Users\Model\Behavior;
use ArrayObject;
+use CakeDC\Users\Email\EmailSender;
use CakeDC\Users\Exception\AccountAlreadyActiveException;
use CakeDC\Users\Exception\AccountNotActiveException;
use CakeDC\Users\Exception\MissingEmailException;
@@ -45,6 +46,8 @@ public function initialize(array $config)
'joinType' => 'INNER',
'className' => Configure::read('Users.table')
]);
+ $this->Email = new EmailSender();
+
}
/**
@@ -77,18 +80,8 @@ public function afterSave(Event $event, Entity $entity, $options)
*/
public function sendSocialValidationEmail(EntityInterface $socialAccount, EntityInterface $user, Email $email = null)
{
- $emailInstance = $this->_getEmailInstance($email);
- if (empty($email)) {
- $emailInstance->template('CakeDC/Users.social_account_validation');
- }
- $firstName = isset($user['first_name'])? $user['first_name'] . ', ' : '';
- //note: we control the space after the username in the previous line
- $subject = __d('Users', '{0}Your social account validation link', $firstName);
- return $emailInstance
- ->to($user['email'])
- ->subject($subject)
- ->viewVars(compact('user', 'socialAccount'))
- ->send();
+ $this->Email = new EmailSender();
+ $this->Email->sendSocialValidationEmail($socialAccount, $user, $email);
}
/**
diff --git a/tests/TestCase/Email/EmailSenderTest.php b/tests/TestCase/Email/EmailSenderTest.php
new file mode 100644
index 000000000..0129389b3
--- /dev/null
+++ b/tests/TestCase/Email/EmailSenderTest.php
@@ -0,0 +1,159 @@
+EmailSender = $this->getMockBuilder('CakeDC\Users\Email\EmailSender')
+ ->setMethods(['_getEmailInstance', 'getMailer'])
+ ->getMock();
+
+ $this->UserMailer = $this->getMockBuilder('CakeDC\Users\Mailer\UserMailer')
+ ->setMethods(['send'])
+ ->getMock();
+
+ $this->fullBaseBackup = Router::fullBaseUrl();
+ Router::fullBaseUrl('http://users.test');
+
+ Email::configTransport('test', [
+ 'className' => 'Debug'
+ ]);
+ }
+
+ /**
+ * tearDown
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ Email::drop('default');
+ Email::dropTransport('test');
+ parent::tearDown();
+ }
+
+ /**
+ * test sendValidationEmail
+ *
+ * @return void
+ */
+ public function testSendEmailValidation()
+ {
+ $table = TableRegistry::get('CakeDC/Users.Users');
+ $user = $table->newEntity([
+ 'first_name' => 'FirstName',
+ 'email' => 'test@example.com',
+ 'token' => '12345'
+ ]);
+
+ $email = new Email([
+ 'from' => 'test@example.com',
+ 'transport' => 'test',
+ 'emailFormat' => 'both',
+ ]);
+
+ $this->EmailSender->expects($this->once())
+ ->method('getMailer')
+ ->with('CakeDC/Users.User')
+ ->will($this->returnValue($this->UserMailer));
+
+ $this->UserMailer->expects($this->once())
+ ->method('send')
+ ->with('validation', [$user, 'Your account validation link']);
+
+ $this->EmailSender->sendValidationEmail($user, $email);
+ }
+
+ /**
+ * test sendResetPasswordEmail
+ *
+ * @return void
+ */
+ public function testSendResetPasswordEmailMailer()
+ {
+ $table = TableRegistry::get('CakeDC/Users.Users');
+ $user = $table->newEntity([
+ 'first_name' => 'FirstName',
+ 'email' => 'test@example.com',
+ 'token' => '12345'
+ ]);
+
+ $email = new Email([
+ 'from' => 'test@example.com',
+ 'transport' => 'test',
+ 'template' => 'CakeDC/Users.reset_password',
+ 'emailFormat' => 'both',
+ ]);
+
+ $this->EmailSender->expects($this->once())
+ ->method('getMailer')
+ ->with('CakeDC/Users.User')
+ ->will($this->returnValue($this->UserMailer));
+
+ $this->UserMailer->expects($this->once())
+ ->method('send')
+ ->with('resetPassword', [$user, 'CakeDC/Users.reset_password']);
+
+ $this->EmailSender->sendResetPasswordEmail($user, $email);
+ }
+
+ /**
+ * test sendSocialValidationEmail
+ *
+ * @return void
+ */
+ public function testSendSocialValidationEmailMailer()
+ {
+ $this->Table = TableRegistry::get('CakeDC/Users.SocialAccounts');
+ $user = $this->Table->find()->contain('Users')->first();
+ $email = new Email([
+ 'from' => 'test@example.com',
+ 'transport' => 'test',
+ 'template' => 'CakeDC/Users.my_template',
+ 'emailFormat' => 'both',
+ ]);
+
+ $this->EmailSender->expects($this->once())
+ ->method('getMailer')
+ ->with('CakeDC/Users.User')
+ ->will($this->returnValue($this->UserMailer));
+
+ $this->UserMailer->expects($this->once())
+ ->method('send')
+ ->with('socialAccountValidation', [$user->user, $user, 'CakeDC/Users.my_template']);
+
+ $this->EmailSender->sendSocialValidationEmail($user, $user->user, $email);
+ }
+}
diff --git a/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php b/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php
index f782e0d0c..7fe78fe90 100644
--- a/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php
+++ b/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php
@@ -46,6 +46,9 @@ public function setUp()
->setMethods(['sendResetPasswordEmail'])
->setConstructorArgs([$this->table])
->getMock();
+ $this->Behavior->Email = $this->getMockBuilder('CakeDC\Users\Email\EmailSender')
+ ->setMethods(['sendResetPasswordEmail'])
+ ->getMock();
}
/**
@@ -68,7 +71,7 @@ public function testResetToken()
{
$user = $this->table->findAllByUsername('user-1')->first();
$token = $user->token;
- $this->Behavior->expects($this->never())
+ $this->Behavior->Email->expects($this->never())
->method('sendResetPasswordEmail')
->with($user);
$result = $this->Behavior->resetToken('user-1', [
@@ -89,7 +92,7 @@ public function testResetTokenSendEmail()
$user = $this->table->findAllByUsername('user-1')->first();
$token = $user->token;
$tokenExpires = $user->token_expires;
- $this->Behavior->expects($this->once())
+ $this->Behavior->Email->expects($this->once())
->method('sendResetPasswordEmail');
$result = $this->Behavior->resetToken('user-1', [
'expiration' => 3600,
@@ -149,7 +152,7 @@ public function testResetTokenUserAlreadyActive()
*
* @return void
*/
- public function testSendResetPasswordEmail()
+ /* public function testSendResetPasswordEmail()
{
$behavior = $this->table->behaviors()->Password;
$this->fullBaseBackup = Router::fullBaseUrl();
@@ -208,5 +211,5 @@ public function testSendResetPasswordEmail()
Router::fullBaseUrl($this->fullBaseBackup);
Email::dropTransport('test');
- }
+ }*/
}
diff --git a/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php b/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php
index 2c0344bb7..e7924891b 100644
--- a/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php
+++ b/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php
@@ -44,16 +44,6 @@ public function setUp()
parent::setUp();
$this->Table = TableRegistry::get('CakeDC/Users.SocialAccounts');
$this->Behavior = $this->Table->behaviors()->SocialAccount;
- $this->fullBaseBackup = Router::fullBaseUrl();
- Router::fullBaseUrl('http://users.test');
- Email::configTransport('test', [
- 'className' => 'Debug'
- ]);
- $this->Email = new Email([
- 'from' => 'test@example.com',
- 'transport' => 'test',
- 'template' => 'CakeDC/Users.social_account_validation',
- ]);
}
/**
@@ -64,8 +54,6 @@ public function setUp()
public function tearDown()
{
unset($this->Table, $this->Behavior, $this->Email);
- Router::fullBaseUrl($this->fullBaseBackup);
- Email::dropTransport('test');
parent::tearDown();
}
@@ -156,7 +144,7 @@ public function testAfterSaveSocialActiveUserNotActive()
*
* @return void
*/
- public function testSendSocialValidationEmail()
+ /* public function testSendSocialValidationEmail()
{
$user = $this->Table->find()->contain('Users')->first();
$this->Email->emailFormat('both');
@@ -167,5 +155,5 @@ public function testSendSocialValidationEmail()
$this->assertTextContains('Hi first1,', $result['message']);
$this->assertTextContains('Activate your social login here', $result['message']);
$this->assertTextContains('If the link is not correcly displayed, please copy the following address in your web browser http://users.test/users/social-accounts/validate-account/Facebook/reference-1-1234/token-1234', $result['message']);
- }
+ }*/
}
From 741721255b8d998f27c9fa7dd0f2504dfbc49495 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Thu, 8 Oct 2015 14:26:50 +0100
Subject: [PATCH 0216/1397] refs #prefixes add prefix matcher for RBAC
permission rules
---
Docs/Documentation/SimpleRbacAuthorize.md | 11 ++-
config/permissions.php | 11 ++-
src/Auth/SimpleRbacAuthorize.php | 6 ++
.../TestCase/Auth/SimpleRbacAuthorizeTest.php | 95 +++++++++++++++++++
4 files changed, 113 insertions(+), 10 deletions(-)
diff --git a/Docs/Documentation/SimpleRbacAuthorize.md b/Docs/Documentation/SimpleRbacAuthorize.md
index d029bcca5..3eb2a109f 100644
--- a/Docs/Documentation/SimpleRbacAuthorize.md
+++ b/Docs/Documentation/SimpleRbacAuthorize.md
@@ -54,11 +54,12 @@ Permission rules syntax
* Each rule is defined:
```php
[
- 'role' => 'REQUIRED_NAME_OF_THE_ROLE_OR_*',
- 'plugin' => 'OPTIONAL_NAME_OF_THE_PLUGIN_OR_*_DEFAULT_NULL',
- 'controller' => 'REQUIRED_NAME_OF_THE_CONTROLLER_OR_*'
- 'action' => 'REQUIRED_NAME_OF_ACTION_OR_*',
- 'allowed' => 'OPTIONAL_BOOLEAN_DEFAULT_TRUE_OR_CALLABLE'
+ 'role' => 'REQUIRED_NAME_OF_THE_ROLE_OR_[]_OR_*',
+ 'prefix' => 'OPTIONAL_PREFIX_USED_OR_[]_OR_*_DEFAULT_NULL',
+ 'plugin' => 'OPTIONAL_NAME_OF_THE_PLUGIN_OR_[]_OR_*_DEFAULT_NULL',
+ 'controller' => 'REQUIRED_NAME_OF_THE_CONTROLLER_OR_[]_OR_*'
+ 'action' => 'REQUIRED_NAME_OF_ACTION_OR_[]_OR_*',
+ 'allowed' => 'OPTIONAL_BOOLEAN_OR_CALLABLE_DEFAULT_TRUE'
]
```
* If no rule allowed = true is matched for a given user role and url, default return value will be false
diff --git a/config/permissions.php b/config/permissions.php
index 1b76eed6c..0f8451259 100644
--- a/config/permissions.php
+++ b/config/permissions.php
@@ -17,12 +17,13 @@
* This is a quick roles-permissions implementation
* Rules are evaluated top-down, first matching rule will apply
* Each line define
- * 'role-name' =>
* [
- * 'plugin', (default = null)
- * 'controller',
- * 'action',
- * 'allowed' (default = true)
+ * 'role' => 'role' | ['roles'] | '*'
+ * 'prefix' => 'Prefix' | , (default = null)
+ * 'plugin' => 'Plugin' | , (default = null)
+ * 'controller' => 'Controller' | ['Controllers'] | '*',
+ * 'action' => 'action' | ['actions'] | '*',
+ * 'allowed' => true | false | callback (default = true)
* ]
* You could use '*' to match anything
* 'allowed' will be considered true if not defined. It allows a callable to manage complex
diff --git a/src/Auth/SimpleRbacAuthorize.php b/src/Auth/SimpleRbacAuthorize.php
index 47256aa6d..aec17e4c3 100644
--- a/src/Auth/SimpleRbacAuthorize.php
+++ b/src/Auth/SimpleRbacAuthorize.php
@@ -44,6 +44,7 @@ class SimpleRbacAuthorize extends BaseAuthorize
* [
* 'role' => 'admin',
* 'plugin', (optional, default = null)
+ * 'prefix', (optional, default = null)
* 'controller',
* 'action',
* 'allowed' (optional, default = true)
@@ -195,7 +196,12 @@ protected function _matchRule($permission, $user, $role, $request)
$plugin = $request->plugin;
$controller = $request->controller;
$action = $request->action;
+ $prefix = null;
+ if (!empty($request->params['prefix'])) {
+ $prefix = $request->params['prefix'];
+ }
if ($this->_matchOrAsterisk($permission, 'role', $role) &&
+ $this->_matchOrAsterisk($permission, 'prefix', $prefix, true) &&
$this->_matchOrAsterisk($permission, 'plugin', $plugin, true) &&
$this->_matchOrAsterisk($permission, 'controller', $controller) &&
$this->_matchOrAsterisk($permission, 'action', $action)) {
diff --git a/tests/TestCase/Auth/SimpleRbacAuthorizeTest.php b/tests/TestCase/Auth/SimpleRbacAuthorizeTest.php
index 9ab9f8ab5..183611b7b 100644
--- a/tests/TestCase/Auth/SimpleRbacAuthorizeTest.php
+++ b/tests/TestCase/Auth/SimpleRbacAuthorizeTest.php
@@ -175,6 +175,10 @@ public function testAuthorize($permissions, $user, $requestParams, $expected, $m
$request->plugin = Hash::get($requestParams, 'plugin');
$request->controller = $requestParams['controller'];
$request->action = $requestParams['action'];
+ $prefix = Hash::get($requestParams, 'prefix');
+ if ($prefix) {
+ $request->params = ['prefix' => $prefix];
+ }
$result = $this->simpleRbacAuthorize->authorize($user, $request);
$this->assertSame($expected, $result, $msg);
@@ -560,6 +564,97 @@ public function providerAuthorize()
//expected
false
],
+ 'happy-prefix' => [
+ //permissions
+ [[
+ 'role' => ['test'],
+ 'prefix' => ['admin'],
+ 'controller' => ['Tests'],
+ 'action' => ['one', 'two'],
+ ]],
+ //user
+ [
+ 'id' => 1,
+ 'username' => 'luke',
+ 'role' => 'test',
+ ],
+ //request
+ [
+ 'prefix' => 'admin',
+ 'controller' => 'Tests',
+ 'action' => 'one'
+ ],
+ //expected
+ true
+ ],
+ 'deny-prefix' => [
+ //permissions
+ [[
+ 'role' => ['test'],
+ 'prefix' => ['admin'],
+ 'controller' => ['Tests'],
+ 'action' => ['one', 'two'],
+ ]],
+ //user
+ [
+ 'id' => 1,
+ 'username' => 'luke',
+ 'role' => 'test',
+ ],
+ //request
+ [
+ 'controller' => 'Tests',
+ 'action' => 'one'
+ ],
+ //expected
+ false
+ ],
+ 'star-prefix' => [
+ //permissions
+ [[
+ 'role' => ['test'],
+ 'prefix' => '*',
+ 'controller' => ['Tests'],
+ 'action' => ['one', 'two'],
+ ]],
+ //user
+ [
+ 'id' => 1,
+ 'username' => 'luke',
+ 'role' => 'test',
+ ],
+ //request
+ [
+ 'prefix' => 'admin',
+ 'controller' => 'Tests',
+ 'action' => 'one'
+ ],
+ //expected
+ true
+ ],
+ 'array-prefix' => [
+ //permissions
+ [[
+ 'role' => ['test'],
+ 'prefix' => ['one', 'admin'],
+ 'controller' => '*',
+ 'action' => '*',
+ ]],
+ //user
+ [
+ 'id' => 1,
+ 'username' => 'luke',
+ 'role' => 'test',
+ ],
+ //request
+ [
+ 'prefix' => 'admin',
+ 'controller' => 'Tests',
+ 'action' => 'one'
+ ],
+ //expected
+ true
+ ],
];
}
}
From 6614dfb0a164a49dd854721e6f32d8d3b2e8e2f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20M=2E=20Gonz=C3=A1lez=20Mart=C3=ADn?=
Date: Thu, 8 Oct 2015 17:33:24 +0100
Subject: [PATCH 0217/1397] Update composer.json
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index cb6dfb871..2071eb2b1 100644
--- a/composer.json
+++ b/composer.json
@@ -4,7 +4,7 @@
"type": "cakephp-plugin",
"require": {
"php": ">=5.4.16",
- "cakephp/cakephp": "~3.1.0"
+ "cakephp/cakephp": "3.1.*"
},
"require-dev": {
"phpunit/phpunit": "*",
From da66d90b80bb3f0329ccc9df6d462ba5d19afc7d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Thu, 15 Oct 2015 17:44:16 +0100
Subject: [PATCH 0218/1397] fix bug on rule calculation when negative rules
matched
---
src/Auth/SimpleRbacAuthorize.php | 7 ++--
.../TestCase/Auth/SimpleRbacAuthorizeTest.php | 32 +++++++++++++++++++
2 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/src/Auth/SimpleRbacAuthorize.php b/src/Auth/SimpleRbacAuthorize.php
index aec17e4c3..5847e5e15 100644
--- a/src/Auth/SimpleRbacAuthorize.php
+++ b/src/Auth/SimpleRbacAuthorize.php
@@ -174,7 +174,8 @@ protected function _checkRules(array $user, $role, Request $request)
{
$permissions = $this->config('permissions');
foreach ($permissions as $permission) {
- if ($allowed = $this->_matchRule($permission, $user, $role, $request)) {
+ $allowed = $this->_matchRule($permission, $user, $role, $request);
+ if ($allowed !== null) {
return $allowed;
}
}
@@ -189,7 +190,7 @@ protected function _checkRules(array $user, $role, Request $request)
* @param array $user current user
* @param string $role effective user role
* @param Request $request request
- * @return bool
+ * @return bool if rule matched, null if rule not matched
*/
protected function _matchRule($permission, $user, $role, $request)
{
@@ -216,7 +217,7 @@ protected function _matchRule($permission, $user, $role, $request)
}
}
- return false;
+ return null;
}
/**
diff --git a/tests/TestCase/Auth/SimpleRbacAuthorizeTest.php b/tests/TestCase/Auth/SimpleRbacAuthorizeTest.php
index 183611b7b..7f84f7878 100644
--- a/tests/TestCase/Auth/SimpleRbacAuthorizeTest.php
+++ b/tests/TestCase/Auth/SimpleRbacAuthorizeTest.php
@@ -655,6 +655,38 @@ public function providerAuthorize()
//expected
true
],
+ 'array-prefix' => [
+ //permissions
+ [
+ [
+ 'role' => ['test'],
+ 'prefix' => ['one', 'admin'],
+ 'controller' => '*',
+ 'action' => 'one',
+ 'allowed' => false,
+ ],
+ [
+ 'role' => ['test'],
+ 'prefix' => ['one', 'admin'],
+ 'controller' => '*',
+ 'action' => '*',
+ ],
+ ],
+ //user
+ [
+ 'id' => 1,
+ 'username' => 'luke',
+ 'role' => 'test',
+ ],
+ //request
+ [
+ 'prefix' => 'admin',
+ 'controller' => 'Tests',
+ 'action' => 'one'
+ ],
+ //expected
+ false
+ ],
];
}
}
From 81ee4f005f231a69bfaf38142be12507a8e52ab4 Mon Sep 17 00:00:00 2001
From: Yelitza Parra
Date: Fri, 23 Oct 2015 06:26:50 -0430
Subject: [PATCH 0219/1397] Renaming UserMailer to UsersMailer
---
src/Email/EmailSender.php | 6 +++---
src/Mailer/{UserMailer.php => UsersMailer.php} | 2 +-
tests/TestCase/Email/EmailSenderTest.php | 6 +++---
3 files changed, 7 insertions(+), 7 deletions(-)
rename src/Mailer/{UserMailer.php => UsersMailer.php} (98%)
diff --git a/src/Email/EmailSender.php b/src/Email/EmailSender.php
index 3f75f6765..b32857bcb 100644
--- a/src/Email/EmailSender.php
+++ b/src/Email/EmailSender.php
@@ -24,7 +24,7 @@ class EmailSender
public function sendValidationEmail(EntityInterface $user, Email $email = null)
{
- $this->getMailer('CakeDC/Users.User',
+ $this->getMailer('CakeDC/Users.Users',
$this->_getEmailInstance($email))->send('validation', [$user, __d('Users', 'Your account validation link')]
);
}
@@ -41,7 +41,7 @@ public function sendValidationEmail(EntityInterface $user, Email $email = null)
*/
public function sendResetPasswordEmail(EntityInterface $user, Email $email = null, $template = 'CakeDC/Users.reset_password')
{
- $this->getMailer('CakeDC/Users.User',
+ $this->getMailer('CakeDC/Users.Users',
$this->_getEmailInstance($email))->send('resetPassword', [$user, $template]
);
}
@@ -61,7 +61,7 @@ public function sendSocialValidationEmail(EntityInterface $socialAccount, Entity
} else {
$template = $email->template()['template'];
}
- $this->getMailer('CakeDC/Users.User',
+ $this->getMailer('CakeDC/Users.Users',
$this->_getEmailInstance($email))->send('socialAccountValidation', [$user, $socialAccount, $template]
);
}
diff --git a/src/Mailer/UserMailer.php b/src/Mailer/UsersMailer.php
similarity index 98%
rename from src/Mailer/UserMailer.php
rename to src/Mailer/UsersMailer.php
index 519f094c8..9fbad5dac 100644
--- a/src/Mailer/UserMailer.php
+++ b/src/Mailer/UsersMailer.php
@@ -18,7 +18,7 @@
* User Mailer
*
*/
-class UserMailer extends Mailer
+class UsersMailer extends Mailer
{
/**
diff --git a/tests/TestCase/Email/EmailSenderTest.php b/tests/TestCase/Email/EmailSenderTest.php
index 0129389b3..c61bd4104 100644
--- a/tests/TestCase/Email/EmailSenderTest.php
+++ b/tests/TestCase/Email/EmailSenderTest.php
@@ -86,7 +86,7 @@ public function testSendEmailValidation()
$this->EmailSender->expects($this->once())
->method('getMailer')
- ->with('CakeDC/Users.User')
+ ->with('CakeDC/Users.Users')
->will($this->returnValue($this->UserMailer));
$this->UserMailer->expects($this->once())
@@ -119,7 +119,7 @@ public function testSendResetPasswordEmailMailer()
$this->EmailSender->expects($this->once())
->method('getMailer')
- ->with('CakeDC/Users.User')
+ ->with('CakeDC/Users.Users')
->will($this->returnValue($this->UserMailer));
$this->UserMailer->expects($this->once())
@@ -147,7 +147,7 @@ public function testSendSocialValidationEmailMailer()
$this->EmailSender->expects($this->once())
->method('getMailer')
- ->with('CakeDC/Users.User')
+ ->with('CakeDC/Users.Users')
->will($this->returnValue($this->UserMailer));
$this->UserMailer->expects($this->once())
From 47125f79560d028421b93056b806bd394e9fbdf1 Mon Sep 17 00:00:00 2001
From: Yelitza Parra
Date: Fri, 23 Oct 2015 11:00:58 -0430
Subject: [PATCH 0220/1397] Adding unit tests to UsersMailer
---
src/Mailer/UsersMailer.php | 14 +-
tests/TestCase/Mailer/UsersMailerTest.php | 218 ++++++++++++++++++
.../Model/Behavior/PasswordBehaviorTest.php | 66 ------
.../Behavior/SocialAccountBehaviorTest.php | 18 --
4 files changed, 222 insertions(+), 94 deletions(-)
create mode 100644 tests/TestCase/Mailer/UsersMailerTest.php
diff --git a/src/Mailer/UsersMailer.php b/src/Mailer/UsersMailer.php
index 9fbad5dac..027e9ed74 100644
--- a/src/Mailer/UsersMailer.php
+++ b/src/Mailer/UsersMailer.php
@@ -30,20 +30,14 @@ class UsersMailer extends Mailer
*
* @return array email send result
*/
- protected function validation(EntityInterface $user, $subject, $template = null)
+ protected function validation(EntityInterface $user, $subject, $template = 'CakeDC/Users.validation')
{
$firstName = isset($user['first_name'])? $user['first_name'] . ', ' : '';
-
$this
->to($user['email'])
->subject($firstName . $subject)
->viewVars($user->toArray())
- ->template('CakeDC/Users.validation');
-
- if (!empty($template)) {
- $this->template($template);
- }
-
+ ->template($template);
}
/**
@@ -61,9 +55,9 @@ protected function resetPassword(EntityInterface $user, $template = 'CakeDC/User
$this
->to($user['email'])
- ->template($template)
->subject($subject)
- ->viewVars($user->toArray());
+ ->viewVars($user->toArray())
+ ->template($template);
}
/**
diff --git a/tests/TestCase/Mailer/UsersMailerTest.php b/tests/TestCase/Mailer/UsersMailerTest.php
new file mode 100644
index 000000000..6fdc8e19c
--- /dev/null
+++ b/tests/TestCase/Mailer/UsersMailerTest.php
@@ -0,0 +1,218 @@
+Email = $this->getMockBuilder('Cake\Mailer\Email')
+ ->setMethods(['to', 'subject', 'viewVars', 'template'])
+ ->getMock();
+
+ $this->UsersMailer = $this->getMockBuilder('CakeDC\Users\Mailer\UsersMailer')
+ ->setConstructorArgs(array($this->Email))
+ ->setMethods(['to', 'subject', 'viewVars', 'template'])
+ ->getMock();
+ }
+
+ /**
+ * tearDown
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ unset($this->UsersMailer);
+ unset($this->Email);
+ parent::tearDown();
+ }
+
+ /**
+ * test sendValidationEmail
+ *
+ * @return void
+ */
+ public function testValidation()
+ {
+ $table = TableRegistry::get('CakeDC/Users.Users');
+ $data = [
+ 'first_name' => 'FirstName',
+ 'email' => 'test@example.com',
+ 'token' => '12345'
+ ];
+ $user = $table->newEntity($data);
+ $this->UsersMailer->expects($this->once())
+ ->method('to')
+ ->with($user['email'])
+ ->will($this->returnValue($this->Email));
+
+ $this->Email->expects($this->once())
+ ->method('subject')
+ ->with('FirstName, Validate your Account')
+ ->will($this->returnValue($this->Email));
+
+ $this->Email->expects($this->once())
+ ->method('viewVars')
+ ->with($data)
+ ->will($this->returnValue($this->Email));
+
+ $this->Email->expects($this->once())
+ ->method('template')
+ ->with('CakeDC/Users.validation')
+ ->will($this->returnValue($this->Email));
+
+ $this->invokeMethod($this->UsersMailer, 'validation', array($user, 'Validate your Account'));
+ }
+
+ /**
+ * test sendValidationEmail including 'template'
+ *
+ * @return void
+ */
+ public function testValidationWithTemplate()
+ {
+ $table = TableRegistry::get('CakeDC/Users.Users');
+ $data = [
+ 'first_name' => 'FirstName',
+ 'email' => 'test@example.com',
+ 'token' => '12345'
+ ];
+ $user = $table->newEntity($data);
+ $this->UsersMailer->expects($this->once())
+ ->method('to')
+ ->with($user['email'])
+ ->will($this->returnValue($this->Email));
+
+ $this->Email->expects($this->once())
+ ->method('subject')
+ ->with('FirstName, Validate your Account')
+ ->will($this->returnValue($this->Email));
+
+ $this->Email->expects($this->once())
+ ->method('viewVars')
+ ->with($data)
+ ->will($this->returnValue($this->Email));
+
+ $this->Email->expects($this->once())
+ ->method('template')
+ ->with('myTemplate')
+ ->will($this->returnValue($this->Email));
+
+ $this->invokeMethod($this->UsersMailer, 'validation', array($user, 'Validate your Account', 'myTemplate'));
+ }
+
+ /**
+ * test SocialAccountValidation
+ *
+ * @return void
+ */
+ public function testSocialAccountValidation()
+ {
+ $social = TableRegistry::get('CakeDC/Users.SocialAccounts')->get('00000000-0000-0000-0000-000000000001', ['contain' => 'Users']);
+
+ $this->UsersMailer->expects($this->once())
+ ->method('to')
+ ->with('user-1@test.com')
+ ->will($this->returnValue($this->Email));
+
+ $this->Email->expects($this->once())
+ ->method('subject')
+ ->with('first1, Your social account validation link')
+ ->will($this->returnValue($this->Email));
+
+
+ $this->Email->expects($this->once())
+ ->method('viewVars')
+ ->with(['user' => $social->user, 'socialAccount' => $social])
+ ->will($this->returnValue($this->Email));
+
+ $this->invokeMethod($this->UsersMailer, 'socialAccountValidation', array($social->user, $social));
+ }
+
+ /**
+ * test sendValidationEmail including 'template'
+ *
+ * @return void
+ */
+ public function testResetPassword()
+ {
+ $table = TableRegistry::get('CakeDC/Users.Users');
+ $data = [
+ 'first_name' => 'FirstName',
+ 'email' => 'test@example.com',
+ 'token' => '12345'
+ ];
+ $user = $table->newEntity($data);
+ $this->UsersMailer->expects($this->once())
+ ->method('to')
+ ->with($user['email'])
+ ->will($this->returnValue($this->Email));
+
+ $this->Email->expects($this->once())
+ ->method('subject')
+ ->with('FirstName, Your reset password link')
+ ->will($this->returnValue($this->Email));
+
+ $this->Email->expects($this->once())
+ ->method('viewVars')
+ ->with($data)
+ ->will($this->returnValue($this->Email));
+
+ $this->Email->expects($this->once())
+ ->method('template')
+ ->with('myTemplate')
+ ->will($this->returnValue($this->Email));
+
+
+ $this->invokeMethod($this->UsersMailer, 'resetPassword', array($user, 'myTemplate'));
+ }
+
+ /**
+ * Call protected/private method of a class.
+ *
+ * @param object &$object Instantiated object that we will run method on.
+ * @param string $methodName Method name to call
+ * @param array $parameters Array of parameters to pass into method.
+ *
+ * @return mixed Method return.
+ */
+ public function invokeMethod(&$object, $methodName, array $parameters = array())
+ {
+ $reflection = new \ReflectionClass(get_class($object));
+ $method = $reflection->getMethod($methodName);
+ $method->setAccessible(true);
+
+ return $method->invokeArgs($object, $parameters);
+ }
+}
diff --git a/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php b/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php
index 7fe78fe90..238a7923d 100644
--- a/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php
+++ b/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php
@@ -146,70 +146,4 @@ public function testResetTokenUserAlreadyActive()
'checkActive' => true,
]);
}
-
- /**
- * Test method
- *
- * @return void
- */
- /* public function testSendResetPasswordEmail()
- {
- $behavior = $this->table->behaviors()->Password;
- $this->fullBaseBackup = Router::fullBaseUrl();
- Router::fullBaseUrl('http://users.test');
- Email::configTransport('test', [
- 'className' => 'Debug'
- ]);
- $this->Email = new Email([
- 'from' => 'test@example.com',
- 'transport' => 'test',
- 'template' => 'CakeDC/Users.reset_password',
- 'emailFormat' => 'both',
- ]);
-
- $user = $this->table->newEntity([
- 'first_name' => 'FirstName',
- 'email' => 'test@example.com',
- 'token' => '12345'
- ]);
-
- $result = $behavior->sendResetPasswordEmail($user, $this->Email, 'CakeDC/Users.reset_password');
- $this->assertTextContains('From: test@example.com', $result['headers']);
- $this->assertTextContains('To: test@example.com', $result['headers']);
- $this->assertTextContains('Subject: FirstName, Your reset password link', $result['headers']);
- $this->assertTextContains('Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Hi FirstName,
-
-Please copy the following address in your web browser http://users.test/users/users/reset-password/12345
-Thank you,
-', $result['message']);
- $this->assertTextContains('Content-Type: text/html; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-
-
-
- Email/html
-
-
-
-Hi FirstName,
-
-
- Reset your password here
-
-
- If the link is not correcly displayed, please copy the following address in your web browser http://users.test/users/users/reset-password/12345
-
- Thank you,
-
-
-
-', $result['message']);
-
- Router::fullBaseUrl($this->fullBaseBackup);
- Email::dropTransport('test');
- }*/
}
diff --git a/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php b/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php
index e7924891b..8bfc5b5a5 100644
--- a/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php
+++ b/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php
@@ -138,22 +138,4 @@ public function testAfterSaveSocialActiveUserNotActive()
$entity = $this->Table->findById('00000000-0000-0000-0000-000000000002')->first();
$this->assertTrue($this->Behavior->afterSave($event, $entity, []));
}
-
- /**
- * Test sendSocialValidationEmail method
- *
- * @return void
- */
- /* public function testSendSocialValidationEmail()
- {
- $user = $this->Table->find()->contain('Users')->first();
- $this->Email->emailFormat('both');
- $result = $this->Behavior->sendSocialValidationEmail($user, $user->user, $this->Email);
- $this->assertTextContains('From: test@example.com', $result['headers']);
- $this->assertTextContains('To: user-1@test.com', $result['headers']);
- $this->assertTextContains('Subject: first1, Your social account validation link', $result['headers']);
- $this->assertTextContains('Hi first1,', $result['message']);
- $this->assertTextContains('Activate your social login here', $result['message']);
- $this->assertTextContains('If the link is not correcly displayed, please copy the following address in your web browser http://users.test/users/social-accounts/validate-account/Facebook/reference-1-1234/token-1234', $result['message']);
- }*/
}
From 1863dc7fdbf37a33e5aae0948cc8ebb565211084 Mon Sep 17 00:00:00 2001
From: Yelitza Parra
Date: Fri, 23 Oct 2015 11:18:59 -0430
Subject: [PATCH 0221/1397] Fixing code standards
---
src/Email/EmailSender.php | 38 ++++++++++++++------
src/Mailer/UsersMailer.php | 2 --
src/Model/Behavior/SocialAccountBehavior.php | 1 -
tests/TestCase/Email/EmailSenderTest.php | 6 ++--
tests/TestCase/Mailer/UsersMailerTest.php | 21 ++++++-----
5 files changed, 43 insertions(+), 25 deletions(-)
diff --git a/src/Email/EmailSender.php b/src/Email/EmailSender.php
index b32857bcb..9b08f4121 100644
--- a/src/Email/EmailSender.php
+++ b/src/Email/EmailSender.php
@@ -10,9 +10,9 @@
*/
namespace CakeDC\Users\Email;
+use Cake\Datasource\EntityInterface;
use Cake\Mailer\Email;
use Cake\Mailer\MailerAwareTrait;
-use Cake\Datasource\EntityInterface;
/**
* Email sender class
@@ -22,11 +22,21 @@ class EmailSender
{
use MailerAwareTrait;
+ /**
+ * Send validation email
+ *
+ * @param EntityInterface $user User entity
+ * @param Email $email instance, if null the default email configuration with the
+ * @return void
+ */
public function sendValidationEmail(EntityInterface $user, Email $email = null)
{
- $this->getMailer('CakeDC/Users.Users',
- $this->_getEmailInstance($email))->send('validation', [$user, __d('Users', 'Your account validation link')]
- );
+ $this
+ ->getMailer(
+ 'CakeDC/Users.Users',
+ $this->_getEmailInstance($email)
+ )
+ ->send('validation', [$user, __d('Users', 'Your account validation link')]);
}
/**
@@ -41,9 +51,12 @@ public function sendValidationEmail(EntityInterface $user, Email $email = null)
*/
public function sendResetPasswordEmail(EntityInterface $user, Email $email = null, $template = 'CakeDC/Users.reset_password')
{
- $this->getMailer('CakeDC/Users.Users',
- $this->_getEmailInstance($email))->send('resetPassword', [$user, $template]
- );
+ $this
+ ->getMailer(
+ 'CakeDC/Users.Users',
+ $this->_getEmailInstance($email)
+ )
+ ->send('resetPassword', [$user, $template]);
}
/**
@@ -61,9 +74,12 @@ public function sendSocialValidationEmail(EntityInterface $socialAccount, Entity
} else {
$template = $email->template()['template'];
}
- $this->getMailer('CakeDC/Users.Users',
- $this->_getEmailInstance($email))->send('socialAccountValidation', [$user, $socialAccount, $template]
- );
+ $this
+ ->getMailer(
+ 'CakeDC/Users.Users',
+ $this->_getEmailInstance($email)
+ )
+ ->send('socialAccountValidation', [$user, $socialAccount, $template]);
}
/**
@@ -80,4 +96,4 @@ protected function _getEmailInstance(Email $email = null)
}
return $email;
}
-}
\ No newline at end of file
+}
diff --git a/src/Mailer/UsersMailer.php b/src/Mailer/UsersMailer.php
index 027e9ed74..4f51359a5 100644
--- a/src/Mailer/UsersMailer.php
+++ b/src/Mailer/UsersMailer.php
@@ -20,7 +20,6 @@
*/
class UsersMailer extends Mailer
{
-
/**
* Send the templated email to the user
*
@@ -79,4 +78,3 @@ protected function socialAccountValidation(EntityInterface $user, EntityInterfac
->viewVars(compact('user', 'socialAccount'));
}
}
-
diff --git a/src/Model/Behavior/SocialAccountBehavior.php b/src/Model/Behavior/SocialAccountBehavior.php
index 1c8cf8b7d..f6c87f01b 100644
--- a/src/Model/Behavior/SocialAccountBehavior.php
+++ b/src/Model/Behavior/SocialAccountBehavior.php
@@ -47,7 +47,6 @@ public function initialize(array $config)
'className' => Configure::read('Users.table')
]);
$this->Email = new EmailSender();
-
}
/**
diff --git a/tests/TestCase/Email/EmailSenderTest.php b/tests/TestCase/Email/EmailSenderTest.php
index c61bd4104..a08755b5b 100644
--- a/tests/TestCase/Email/EmailSenderTest.php
+++ b/tests/TestCase/Email/EmailSenderTest.php
@@ -11,11 +11,13 @@
namespace CakeDC\Users\Test\TestCase\Email;
use Cake\Mailer\Email;
-use Cake\TestSuite\TestCase;
use Cake\ORM\TableRegistry;
-use CakeDC\Users\Mailer\UserMailer;
use Cake\Routing\Router;
+use Cake\TestSuite\TestCase;
+/**
+ * Test Case
+ */
class EmailSenderTest extends TestCase
{
/**
diff --git a/tests/TestCase/Mailer/UsersMailerTest.php b/tests/TestCase/Mailer/UsersMailerTest.php
index 6fdc8e19c..1aae78b62 100644
--- a/tests/TestCase/Mailer/UsersMailerTest.php
+++ b/tests/TestCase/Mailer/UsersMailerTest.php
@@ -11,11 +11,13 @@
namespace CakeDC\Users\Test\TestCase\Email;
use Cake\Mailer\Email;
-use Cake\TestSuite\TestCase;
use Cake\ORM\TableRegistry;
-use CakeDC\Users\Mailer\UserMailer;
use Cake\Routing\Router;
+use Cake\TestSuite\TestCase;
+/**
+ * Test Case
+ */
class UsersMailerTest extends TestCase
{
/**
@@ -41,7 +43,7 @@ public function setUp()
->getMock();
$this->UsersMailer = $this->getMockBuilder('CakeDC\Users\Mailer\UsersMailer')
- ->setConstructorArgs(array($this->Email))
+ ->setConstructorArgs([$this->Email])
->setMethods(['to', 'subject', 'viewVars', 'template'])
->getMock();
}
@@ -92,7 +94,7 @@ public function testValidation()
->with('CakeDC/Users.validation')
->will($this->returnValue($this->Email));
- $this->invokeMethod($this->UsersMailer, 'validation', array($user, 'Validate your Account'));
+ $this->invokeMethod($this->UsersMailer, 'validation', [$user, 'Validate your Account']);
}
/**
@@ -129,7 +131,7 @@ public function testValidationWithTemplate()
->with('myTemplate')
->will($this->returnValue($this->Email));
- $this->invokeMethod($this->UsersMailer, 'validation', array($user, 'Validate your Account', 'myTemplate'));
+ $this->invokeMethod($this->UsersMailer, 'validation', [$user, 'Validate your Account', 'myTemplate']);
}
/**
@@ -139,7 +141,8 @@ public function testValidationWithTemplate()
*/
public function testSocialAccountValidation()
{
- $social = TableRegistry::get('CakeDC/Users.SocialAccounts')->get('00000000-0000-0000-0000-000000000001', ['contain' => 'Users']);
+ $social = TableRegistry::get('CakeDC/Users.SocialAccounts')
+ ->get('00000000-0000-0000-0000-000000000001', ['contain' => 'Users']);
$this->UsersMailer->expects($this->once())
->method('to')
@@ -157,7 +160,7 @@ public function testSocialAccountValidation()
->with(['user' => $social->user, 'socialAccount' => $social])
->will($this->returnValue($this->Email));
- $this->invokeMethod($this->UsersMailer, 'socialAccountValidation', array($social->user, $social));
+ $this->invokeMethod($this->UsersMailer, 'socialAccountValidation', [$social->user, $social]);
}
/**
@@ -195,7 +198,7 @@ public function testResetPassword()
->will($this->returnValue($this->Email));
- $this->invokeMethod($this->UsersMailer, 'resetPassword', array($user, 'myTemplate'));
+ $this->invokeMethod($this->UsersMailer, 'resetPassword', [$user, 'myTemplate']);
}
/**
@@ -207,7 +210,7 @@ public function testResetPassword()
*
* @return mixed Method return.
*/
- public function invokeMethod(&$object, $methodName, array $parameters = array())
+ public function invokeMethod(&$object, $methodName, $parameters = [])
{
$reflection = new \ReflectionClass(get_class($object));
$method = $reflection->getMethod($methodName);
From 0f6400e25b122ceb7a153c8da163b823f036cdc1 Mon Sep 17 00:00:00 2001
From: Alejandro Ibarra
Date: Fri, 23 Oct 2015 11:42:43 -0500
Subject: [PATCH 0222/1397] Implement change from opauth to phpleague/oauth
---
composer.json | 11 +-
config/bootstrap.php | 7 ++
config/routes.php | 7 +-
config/users.php | 36 +++---
src/Auth/Factory/OpauthFactory.php | 35 ------
src/Auth/Social/Mapper/AbstractMapper.php | 103 ++++++++++++++++++
src/Auth/Social/Mapper/Facebook.php | 31 ++++++
src/Auth/Social/Mapper/Instagram.php | 39 +++++++
src/Auth/Social/Mapper/LinkedIn.php | 15 +++
src/Auth/Social/Mapper/Twitter.php | 15 +++
src/Auth/Social/Util/SocialUtils.php | 25 +++++
src/Auth/SocialAuthenticate.php | 77 ++++++++-----
.../Component/UsersAuthComponent.php | 24 +---
src/Controller/Traits/LoginTrait.php | 6 +-
src/Controller/Traits/SocialTrait.php | 47 --------
src/Model/Behavior/SocialBehavior.php | 101 ++++++++---------
src/Model/Table/SocialAccountsTable.php | 2 +
17 files changed, 363 insertions(+), 218 deletions(-)
delete mode 100644 src/Auth/Factory/OpauthFactory.php
create mode 100644 src/Auth/Social/Mapper/AbstractMapper.php
create mode 100644 src/Auth/Social/Mapper/Facebook.php
create mode 100644 src/Auth/Social/Mapper/Instagram.php
create mode 100644 src/Auth/Social/Mapper/LinkedIn.php
create mode 100644 src/Auth/Social/Mapper/Twitter.php
create mode 100644 src/Auth/Social/Util/SocialUtils.php
diff --git a/composer.json b/composer.json
index 2071eb2b1..a3bd60a99 100644
--- a/composer.json
+++ b/composer.json
@@ -7,15 +7,12 @@
"cakephp/cakephp": "3.1.*"
},
"require-dev": {
- "phpunit/phpunit": "*",
- "opauth/opauth": "*",
- "opauth/facebook": "*",
- "opauth/twitter": "*"
+ "phpunit/phpunit": "*"
},
"suggest": {
- "opauth/opauth": "Used for Social Login, if you add Opauth, remember adding at least one strategy too",
- "opauth/facebook": "Provide Social Login: Facebook Strategy, requires Opauth",
- "opauth/twitter": "Provide Social Login: Twitter Strategy, requires Opauth",
+ "muffin/oauth2": "Provide Social Authentication",
+ "league/oauth2-facebook": "Provide Social Authentication with Facebook",
+ "league/oauth2-instagram": "Provide Social Authentication with Instagram",
"google/recaptcha": "Provide reCAPTCHA validation for registration form"
},
"autoload": {
diff --git a/config/bootstrap.php b/config/bootstrap.php
index 069ec6f16..19c9b5b6c 100644
--- a/config/bootstrap.php
+++ b/config/bootstrap.php
@@ -10,6 +10,9 @@
*/
use Cake\Core\Configure;
+use Cake\Core\Plugin;
+use Cake\Event\EventManager;
+use Cake\ORM\TableRegistry;
Configure::load('CakeDC/Users.users');
collection((array)Configure::read('Users.config'))->each(function ($file) {
@@ -19,3 +22,7 @@
if (Configure::check('Users.auth')) {
Configure::write('Auth.authenticate.all.userModel', Configure::read('Users.table'));
}
+
+if (Configure::read('Users.Social.login')) {
+ Plugin::load('Muffin/OAuth2');
+}
diff --git a/config/routes.php b/config/routes.php
index 712598f19..103c8a55d 100644
--- a/config/routes.php
+++ b/config/routes.php
@@ -16,12 +16,13 @@
$routes->fallbacks('DashedRoute');
});
-$oauthPath = Configure::read('Opauth.path');
+$oauthPath = Configure::read('OAuth.path');
if (is_array($oauthPath)) {
Router::scope('/auth', function ($routes) use ($oauthPath) {
$routes->connect(
- '/*',
- $oauthPath
+ '/:provider',
+ $oauthPath,
+ ['provider' => implode('|', array_keys(Configure::read('OAuth.providers')))]
);
});
}
diff --git a/config/users.php b/config/users.php
index a9a602d45..c1ccbaa3b 100644
--- a/config/users.php
+++ b/config/users.php
@@ -99,24 +99,28 @@
'CakeDC/Users.SimpleRbac',
],
],
-//default Opauth configuration, you'll need to provide the strategy keys
- 'Opauth' => [
- 'path' => ['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'opauthInit'],
- 'callback_param' => 'callback',
- 'complete_url' => ['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login'],
- 'Strategy' => [
- 'Facebook' => [
- 'scope' => ['public_profile', 'user_friends', 'email'],
- //app_id => 'YOUR_APP_ID',
- //app_secret = 'YOUR_APP_SECRET',
+ 'OAuth' => [
+ 'path' => ['controller' => 'Users', 'action' => 'socialLogin'],
+ 'providers' => [
+ 'facebook' => [
+ 'className' => 'League\OAuth2\Client\Provider\Facebook',
+ 'options' => [
+ 'graphApiVersion' => 'v2.5'
+ ],
+ 'mapFields' => [
+ 'username' => 'login',
+ ],
],
- 'Twitter' => [
- 'curl_cainfo' => false,
- 'curl_capath' => false,
- //'key' => 'YOUR_APP_KEY',
- //'secret' => 'YOUR_APP_SECRET',
+ 'instagram' => [
+ 'className' => 'League\OAuth2\Client\Provider\Instagram',
+ 'options' => [
+ 'graphApiVersion' => 'v2.5'
+ ],
+ 'mapFields' => [
+ 'username' => 'login', // maps the app's username to github's login
+ ],
]
- ]
+ ],
]
];
diff --git a/src/Auth/Factory/OpauthFactory.php b/src/Auth/Factory/OpauthFactory.php
deleted file mode 100644
index 15d61abcd..000000000
--- a/src/Auth/Factory/OpauthFactory.php
+++ /dev/null
@@ -1,35 +0,0 @@
- 'id',
+ 'username' => 'username',
+ 'full_name' => 'name',
+ 'first_name' => 'first_name',
+ 'last_name' => 'last_name',
+ 'email' => 'email',
+ 'avatar' => 'avatar',
+ 'gender' => 'gender',
+ 'link' => 'link',
+ 'bio' => 'bio',
+ 'locale' => 'locale',
+ 'validated' => 'validated'
+ ];
+
+ /**
+ * Constructor
+ *
+ * @param $rawData
+ * @param null $mapFields
+ */
+ public function __construct($rawData, $mapFields = null)
+ {
+ $this->_rawData = $rawData;
+ if (!is_null($mapFields)) {
+ $this->_mapFields = $mapFields;
+ }
+ $this->_mapFields = array_merge($this->_defaultMapFields, $this->_mapFields);
+ }
+ /**
+ * Invoke method
+ */
+ public function __invoke()
+ {
+ return $this->_map();
+ }
+
+ /**
+ * If email is present the user is validated
+ * @return bool
+ */
+ protected function _validated()
+ {
+ return !empty($this->_rawData[$this->_mapFields['email']]);
+ }
+
+ /**
+ * Maps raw data using mapFields
+ *
+ * @return mixed
+ */
+ protected function _map()
+ {
+ $result = [];
+ collection($this->_mapFields)->each(function ($mappedField, $field) use (&$result) {
+ $value = Hash::get($this->_rawData, $mappedField);
+ $function = '_' . $field;
+ if (method_exists($this, $function)) {
+ $value = $this->{$function}();
+ }
+ $result[$field] = $value;
+ });
+ /** @var \League\OAuth2\Client\Token\AccessToken $token **/
+ $token = Hash::get($this->_rawData, 'token');
+ $result['credentials'] = [
+ 'token' => $token->getToken(),
+ 'secret' => null, //todo check when twitter is available
+ 'expires' => $token->getExpires(),
+ ];
+ $result['raw'] = $this->_rawData;
+ return $result;
+ }
+}
diff --git a/src/Auth/Social/Mapper/Facebook.php b/src/Auth/Social/Mapper/Facebook.php
new file mode 100644
index 000000000..1dac33eab
--- /dev/null
+++ b/src/Auth/Social/Mapper/Facebook.php
@@ -0,0 +1,31 @@
+ 'name',
+ ];
+
+ /**
+ * Get avatar url
+ * @return string
+ */
+ protected function _avatar()
+ {
+ return self::FB_GRAPH_BASE_URL . Hash::get($this->_rawData, 'id') . '/picture?type=normal';
+ }
+}
diff --git a/src/Auth/Social/Mapper/Instagram.php b/src/Auth/Social/Mapper/Instagram.php
new file mode 100644
index 000000000..0aaa90a82
--- /dev/null
+++ b/src/Auth/Social/Mapper/Instagram.php
@@ -0,0 +1,39 @@
+ 'data.profile_picture',
+ 'id' => 'data.id',
+ 'full_name' => 'data.full_name',
+ 'username' => 'data.username'
+ ];
+
+ /**
+ * @return string
+ */
+ protected function _link()
+ {
+ return self::INSTAGRAM_BASE_URL . Hash::get($this->_rawData, $this->_mapFields['username']);
+ }
+}
diff --git a/src/Auth/Social/Mapper/LinkedIn.php b/src/Auth/Social/Mapper/LinkedIn.php
new file mode 100644
index 000000000..8d62ac3ca
--- /dev/null
+++ b/src/Auth/Social/Mapper/LinkedIn.php
@@ -0,0 +1,15 @@
+getShortName();
+ }
+}
\ No newline at end of file
diff --git a/src/Auth/SocialAuthenticate.php b/src/Auth/SocialAuthenticate.php
index 46bc12e12..a7aca87fd 100755
--- a/src/Auth/SocialAuthenticate.php
+++ b/src/Auth/SocialAuthenticate.php
@@ -11,53 +11,40 @@
namespace CakeDC\Users\Auth;
-use Cake\Auth\BaseAuthenticate;
+use Cake\Controller\ComponentRegistry;
use Cake\Core\Configure;
use Cake\Network\Request;
-use Cake\Network\Response;
use Cake\ORM\TableRegistry;
-use Cake\Utility\Hash;
+use CakeDC\Users\Auth\Social\Util\SocialUtils;
+use Muffin\OAuth2\Auth\OAuthAuthenticate;
/**
* Class SocialAuthenticate
*/
-class SocialAuthenticate extends BaseAuthenticate
+class SocialAuthenticate extends OAuthAuthenticate
{
/**
- * Authenticate callback
+ * Constructor
*
- * @param Request $request Cake request object.
- * @param Response $response Cake response object.
- * @return bool|mixed
+ * @param \Cake\Controller\ComponentRegistry $registry The Component registry used on this request.
+ * @param array $config Array of config to use.
+ * @throws \Exception
*/
- public function authenticate(Request $request, Response $response)
+ public function __construct(ComponentRegistry $registry, array $config = [])
{
- $data = $request->session()->read(Configure::read('Users.Key.Session.social'));
-
- if (empty($data)) {
- return false;
- }
- $socialMail = Hash::get((array)$data->info, Configure::read('Users.Key.Data.email'));
-
- if (!empty($socialMail)) {
- $data->email = $socialMail;
- $data->validated = true;
- } else {
- $data->email = $request->data(Configure::read('Users.Key.Data.email'));
- $data->validated = false;
- }
- $user = $this->_findOrCreateUser($data);
- return $user;
+ Configure::write('Muffin/OAuth2', Configure::read('OAuth'));
+ parent::__construct($registry, array_merge($config, Configure::read('OAuth')));
}
/**
- * Checks the social user against the database
+ * Finds or creates a local user.
*
- * @param array $data User data array.
- * @return mixed
+ * @param array $data Mapped user data.
+ * @return array
+ * @throws \Muffin\OAuth2\Auth\Exception\MissingEventListenerException
*/
- protected function _findOrCreateUser($data)
+ protected function _touch(array $data)
{
$userModel = Configure::read('Users.table');
$User = TableRegistry::get($userModel);
@@ -66,10 +53,40 @@ protected function _findOrCreateUser($data)
'validate_email' => Configure::read('Users.Email.validate'),
'token_expiration' => Configure::read('Users.Token.expiration')
];
- $user = $User->socialLogin($data, $options);
+ $user = $User->socialLogin($data, $options, $this->_provider);
if (!empty($user->username)) {
$user = $this->_findUser($user->username);
}
return $user;
}
+
+ /**
+ * Get a user based on information in the request.
+ *
+ * @param \Cake\Network\Request $request Request object.
+ * @return mixed Either false or an array of user information
+ * @throws \RuntimeException If the `Muffin/OAuth2.newUser` event is missing or returns empty.
+ */
+ public function getUser(Request $request)
+ {
+ if (!$rawData = $this->_authenticate($request)) {
+ return false;
+ }
+ $provider = SocialUtils::getProvider($this->_provider);
+ $providerMapperClass = "\\CakeDC\\Users\\Auth\\Social\\Mapper\\$provider";
+ $providerMapper = new $providerMapperClass($rawData);
+ $user = $providerMapper();
+
+ if (!$user || !$this->config('userModel')) {
+ return false;
+ }
+
+ if (!$result = $this->_touch($user)) {
+ return false;
+ }
+
+ $args = [$this->_provider, $result];
+ $this->dispatchEvent('Muffin/OAuth2.afterIdentify', $args);
+ return $result;
+ }
}
diff --git a/src/Controller/Component/UsersAuthComponent.php b/src/Controller/Component/UsersAuthComponent.php
index c75ed3d51..b9b32a314 100644
--- a/src/Controller/Component/UsersAuthComponent.php
+++ b/src/Controller/Component/UsersAuthComponent.php
@@ -43,9 +43,6 @@ public function initialize(array $config)
$this->_validateConfig();
$this->_initAuth();
- if (Configure::read('Users.Social.login') && Configure::read('Opauth')) {
- $this->_configOpauthRoutes();
- }
if (Configure::read('Users.Social.login')) {
$this->_loadSocialLogin();
}
@@ -106,10 +103,11 @@ protected function _initAuth()
'resendTokenValidation',
'login',
'socialEmail',
- 'opauthInit',
'resetPassword',
'requestResetPassword',
'changePassword',
+ 'endpoint',
+ 'authenticated'
]);
}
@@ -158,22 +156,4 @@ protected function _validateConfig()
throw new BadConfigurationException($message);
}
}
-
- /**
- * Config Opauth urls
- *
- * @return void
- */
- protected function _configOpauthRoutes()
- {
- $path = Configure::read('Opauth.path');
- Configure::write('Opauth.path', Router::url($path) . '/');
- //Generate callback url
- if (is_array($path)) {
- $path[] = Configure::read('Opauth.callback_param');
- } else {
- $path = $path . Configure::read('Opauth.callback_param');
- }
- Configure::write('Opauth.callback_url', Router::url($path));
- }
}
diff --git a/src/Controller/Traits/LoginTrait.php b/src/Controller/Traits/LoginTrait.php
index afde464af..fd1200574 100644
--- a/src/Controller/Traits/LoginTrait.php
+++ b/src/Controller/Traits/LoginTrait.php
@@ -25,6 +25,10 @@ trait LoginTrait
{
use CustomUsersTableTrait;
+ public function socialLogin()
+ {
+
+ }
/**
* Login user
*
@@ -49,8 +53,6 @@ public function login()
$user = $this->Auth->identify();
return $this->_afterIdentifyUser($user, $socialLogin);
} catch (AccountNotActiveException $ex) {
- $socialKey = Configure::read('Users.Key.Session.social');
- $this->request->session()->delete($socialKey);
$msg = __d('Users', 'Your social account has not been validated yet. Please check your inbox for instructions');
$this->Flash->success($msg);
} catch (MissingEmailException $ex) {
diff --git a/src/Controller/Traits/SocialTrait.php b/src/Controller/Traits/SocialTrait.php
index ba788c7d8..ecb5bba72 100644
--- a/src/Controller/Traits/SocialTrait.php
+++ b/src/Controller/Traits/SocialTrait.php
@@ -11,10 +11,8 @@
namespace CakeDC\Users\Controller\Traits;
-use CakeDC\Users\Auth\Factory\OpauthFactory;
use Cake\Core\Configure;
use Cake\Network\Exception\NotFoundException;
-use Cake\Routing\Router;
/**
* Covers registration features and email token validation
@@ -22,41 +20,6 @@
*/
trait SocialTrait
{
-
- /**
- * Start Opauth authentication
- *
- * @param bool|false $callback callback
- * @return void
- */
- public function opauthInit($callback = null)
- {
- $this->autoRender = false;
- $Opauth = $this->_getOpauthInstance();
- $response = $Opauth->run();
- if (empty($callback)) {
- return;
- }
- $url = $this->_generateOpauthCompleteUrl();
- $this->request->session()->write(Configure::read('Users.Key.Session.social'), $response);
- return $this->redirect($url);
- }
-
- /**
- * Generates the opauth callback url
- *
- * @return string Full translated URL with base path.
- */
- protected function _generateOpauthCompleteUrl()
- {
- $url = Configure::read('Opauth.complete_url');
- if (!is_array($url)) {
- $url = Router::parse($url);
- }
- $url['?'] = ['social' => $this->request->query('code')];
- return Router::url($url, true);
- }
-
/**
* Render the social email form
*
@@ -69,14 +32,4 @@ public function socialEmail()
throw new NotFoundException();
}
}
-
- /**
- * Gets OpauthFactory instance
- *
- * @return OpauthFactory
- */
- protected function _getOpauthInstance()
- {
- return OpauthFactory::create(Configure::read('Opauth'));
- }
}
diff --git a/src/Model/Behavior/SocialBehavior.php b/src/Model/Behavior/SocialBehavior.php
index 0da027e8c..7e0d6d82b 100644
--- a/src/Model/Behavior/SocialBehavior.php
+++ b/src/Model/Behavior/SocialBehavior.php
@@ -11,6 +11,9 @@
namespace CakeDC\Users\Model\Behavior;
+use Cake\Event\Event;
+use Cake\Event\EventDispatcherTrait;
+use CakeDC\Users\Auth\Social\Util\SocialUtils;
use CakeDC\Users\Exception\AccountNotActiveException;
use CakeDC\Users\Exception\MissingEmailException;
use CakeDC\Users\Model\Behavior\Behavior;
@@ -20,6 +23,9 @@
use Cake\Utility\Hash;
use DateTime;
use InvalidArgumentException;
+use League\OAuth2\Client\Provider\AbstractProvider;
+use League\OAuth2\Client\Provider\Facebook;
+use ReflectionClass;
/**
* Covers social features
@@ -28,28 +34,28 @@
class SocialBehavior extends Behavior
{
use RandomStringTrait;
-
- /**
- * Used to create a default profile link if not available in raw data returned by FB
- */
- const FACEBOOK_SCOPED_ID_URL = "https://www.facebook.com/app_scoped_user_id/";
+ use EventDispatcherTrait;
/**
* Performs social login
*
* @param array $data Array social login.
* @param array $options Array option data.
+ * @param AbstractProvider $provider Provider
* @return bool|EntityInterface|mixed
*/
- public function socialLogin($data, $options = [])
+ public function socialLogin(array $data, array $options, AbstractProvider $provider)
{
- $provider = $data->provider;
- $reference = $data->uid;
+ $data['provider'] = SocialUtils::getProvider($provider);
+ $reference = Hash::get($data, 'id');
$existingAccount = $this->_table->SocialAccounts->find()
- ->where(['SocialAccounts.reference' => $reference, 'SocialAccounts.provider' => $provider])
+ ->where(['SocialAccounts.reference' => $reference, 'SocialAccounts.provider' => $data['provider']])
->contain(['Users'])
->first();
if (empty($existingAccount->user)) {
+ $event = 'Muffin/OAuth2.newUser';
+ $args = [$provider, $data];
+ $this->dispatchEvent($event, $args);
$user = $this->_createSocialUser($data, $options);
if (!empty($user->social_accounts[0])) {
$existingAccount = $user->social_accounts[0];
@@ -86,11 +92,12 @@ protected function _createSocialUser($data, $options = [])
$validateEmail = Hash::get($options, 'validate_email');
$tokenExpiration = Hash::get($options, 'token_expiration');
$existingUser = null;
- if ($useEmail && empty($data->email)) {
+ $email = Hash::get($data, 'email');
+ if ($useEmail && empty($email)) {
throw new MissingEmailException(__d('Users', 'Email not present'));
} else {
$existingUser = $this->_table->find()
- ->where([$this->_table->alias() . '.email' => $data->email])
+ ->where([$this->_table->alias() . '.email' => $email])
->first();
}
$user = $this->_populateUser($data, $existingUser, $useEmail, $validateEmail, $tokenExpiration);
@@ -112,42 +119,38 @@ protected function _createSocialUser($data, $options = [])
*/
protected function _populateUser($data, $existingUser, $useEmail, $validateEmail, $tokenExpiration)
{
- $accountData['provider'] = $data->provider;
- $accountData['username'] = Hash::get((array)$data->info, 'nickname');
- $accountData['reference'] = $data->uid;
- $accountData['avatar'] = Hash::get((array)$data->info, 'image');
- /* @todo make a pull request to Opauth Facebook Strategy because it does not include link on info array */
- if ($data->provider == SocialAccountsTable::PROVIDER_TWITTER) {
- $accountData['link'] = Hash::get((array)$data->info, 'urls.twitter');
- } elseif ($data->provider == SocialAccountsTable::PROVIDER_FACEBOOK) {
- $accountData['link'] = $this->_getFacebookLink($data->raw);
- }
+ $accountData['provider'] = Hash::get($data, 'provider');
+ $accountData['username'] = Hash::get($data, 'username');
+ $accountData['reference'] = Hash::get($data, 'id');
+ $accountData['avatar'] = Hash::get($data, 'avatar');
+ $accountData['link'] = Hash::get($data, 'link');
+
$accountData['avatar'] = str_replace('square', 'large', $accountData['avatar']);
- $accountData['description'] = Hash::get((array)$data->info, 'description');
- $accountData['token'] = Hash::get((array)$data->credentials, 'token');
- $accountData['token_secret'] = Hash::get((array)$data->credentials, 'secret');
- $expires = Hash::get((array)$data->credentials, 'expires');
+ $accountData['description'] = Hash::get($data, 'bio');
+ $accountData['token'] = Hash::get($data, 'credentials.token');
+ $accountData['token_secret'] = Hash::get($data, 'credentials.secret');
+ $expires = Hash::get($data, 'credentials.expires');
$accountData['token_expires'] = !empty($expires) ? (new DateTime($expires))->format('Y-m-d H:i:s') : null;
- $accountData['data'] = serialize($data->raw);
+ $accountData['data'] = serialize(Hash::get($data, 'raw'));
$accountData['active'] = true;
if (empty($existingUser)) {
- $firstName = Hash::get((array)$data->info, 'first_name');
- $lastName = Hash::get((array)$data->info, 'last_name');
+ $firstName = Hash::get($data, 'first_name');
+ $lastName = Hash::get($data, 'last_name');
if (!empty($firstName) && !empty($lastName)) {
$userData['first_name'] = $firstName;
$userData['last_name'] = $lastName;
} else {
- $name = explode(' ', $data->name);
+ $name = explode(' ', Hash::get($data, 'full_name'));
$userData['first_name'] = Hash::get($name, 0);
array_shift($name);
$userData['last_name'] = implode(' ', $name);
}
- $userData['username'] = Hash::get((array)$data->info, 'nickname');
+ $userData['username'] = Hash::get($data, 'username');
$username = Hash::get($userData, 'username');
if (empty($username)) {
- if (!empty($data->email)) {
- $email = explode('@', $data->email);
+ if (!empty(Hash::get($data, 'email'))) {
+ $email = explode('@', Hash::get($data, 'email'));
$userData['username'] = Hash::get($email, 0);
} else {
$firstName = Hash::get($userData, 'first_name');
@@ -157,23 +160,26 @@ protected function _populateUser($data, $existingUser, $useEmail, $validateEmail
}
}
$userData['username'] = $this->generateUniqueUsername(Hash::get($userData, 'username'));
+
if ($useEmail) {
- $userData['email'] = $data->email;
- if (!$data->validated) {
+ $userData['email'] = Hash::get($data, 'email');
+ if (empty(Hash::get($data, 'validated'))) {
$accountData['active'] = false;
}
}
$userData['password'] = $this->randomString();
- $userData['avatar'] = Hash::get((array)$data->info, 'image');
- $userData['validated'] = $data->validated;
+ $userData['avatar'] = Hash::get($data, 'avatar');
+ $userData['validated'] = !empty(Hash::get($data, 'validated'));
$userData['tos_date'] = date("Y-m-d H:i:s");
- $userData['gender'] = Hash::get($data->raw, 'gender');
- $userData['timezone'] = Hash::get($data->raw, 'timezone');
+ $userData['gender'] = Hash::get($data, 'gender');
+ //$userData['timezone'] = Hash::get($data, 'timezone');
$userData['social_accounts'][] = $accountData;
+ debug($userData);
+ die();
$user = $this->_table->newEntity($userData, ['associated' => ['SocialAccounts']]);
$user = $this->_updateActive($user, false, $tokenExpiration);
} else {
- if ($useEmail && !$data->validated) {
+ if ($useEmail && empty(Hash::get($data, 'validated'))) {
$accountData['active'] = false;
}
$user = $this->_table->patchEntity($existingUser, [
@@ -183,23 +189,6 @@ protected function _populateUser($data, $existingUser, $useEmail, $validateEmail
return $user;
}
- /**
- * Create a link for facebook profile
- *
- * @param array $raw raw data array returned by Facebook
- * @return string url to facebook profile
- */
- protected function _getFacebookLink($raw = [])
- {
- $link = Hash::get((array)$raw, 'link');
- if (!empty($link)) {
- return $link;
- }
-
- $id = Hash::get((array)$raw, 'id');
- return self::FACEBOOK_SCOPED_ID_URL . $id;
- }
-
/**
* Checks if username exists and generate a new one
*
diff --git a/src/Model/Table/SocialAccountsTable.php b/src/Model/Table/SocialAccountsTable.php
index 4b139e415..dc06716d2 100644
--- a/src/Model/Table/SocialAccountsTable.php
+++ b/src/Model/Table/SocialAccountsTable.php
@@ -35,6 +35,8 @@ class SocialAccountsTable extends Table
*/
const PROVIDER_TWITTER = 'Twitter';
const PROVIDER_FACEBOOK = 'Facebook';
+ const PROVIDER_INSTAGRAM = 'Instagram';
+ const PROVIDER_LINKEDIN = 'LinkedIn';
/**
* Initialize method
From e54d3d26638426cde20b8f7c926002cd0d3d711b Mon Sep 17 00:00:00 2001
From: Alejandro Ibarra
Date: Sun, 25 Oct 2015 09:11:04 -0500
Subject: [PATCH 0223/1397] Continue switching oauth provider
---
config/users.php | 16 +++++----------
src/Model/Behavior/SocialBehavior.php | 11 ++++++----
src/Model/Table/UsersTable.php | 2 +-
src/Template/Users/login.ctp | 20 +++++++++++-------
src/View/Helper/UserHelper.php | 29 +++++++++------------------
5 files changed, 35 insertions(+), 43 deletions(-)
diff --git a/config/users.php b/config/users.php
index c1ccbaa3b..d96cd1bfa 100644
--- a/config/users.php
+++ b/config/users.php
@@ -100,25 +100,19 @@
],
],
'OAuth' => [
- 'path' => ['controller' => 'Users', 'action' => 'socialLogin'],
+ 'path' => ['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'socialLogin'],
'providers' => [
'facebook' => [
'className' => 'League\OAuth2\Client\Provider\Facebook',
'options' => [
'graphApiVersion' => 'v2.5'
- ],
- 'mapFields' => [
- 'username' => 'login',
- ],
+ ]
],
- 'instagram' => [
- 'className' => 'League\OAuth2\Client\Provider\Instagram',
+ 'linkedIn' => [
+ 'className' => 'League\OAuth2\Client\Provider\LinkedIn',
'options' => [
'graphApiVersion' => 'v2.5'
- ],
- 'mapFields' => [
- 'username' => 'login', // maps the app's username to github's login
- ],
+ ]
]
],
]
diff --git a/src/Model/Behavior/SocialBehavior.php b/src/Model/Behavior/SocialBehavior.php
index 7e0d6d82b..91d6e4b30 100644
--- a/src/Model/Behavior/SocialBehavior.php
+++ b/src/Model/Behavior/SocialBehavior.php
@@ -125,12 +125,17 @@ protected function _populateUser($data, $existingUser, $useEmail, $validateEmail
$accountData['avatar'] = Hash::get($data, 'avatar');
$accountData['link'] = Hash::get($data, 'link');
- $accountData['avatar'] = str_replace('square', 'large', $accountData['avatar']);
+ $accountData['avatar'] = str_replace('normal', 'square', $accountData['avatar']);
$accountData['description'] = Hash::get($data, 'bio');
$accountData['token'] = Hash::get($data, 'credentials.token');
$accountData['token_secret'] = Hash::get($data, 'credentials.secret');
$expires = Hash::get($data, 'credentials.expires');
- $accountData['token_expires'] = !empty($expires) ? (new DateTime($expires))->format('Y-m-d H:i:s') : null;
+ if (!empty($expires)) {
+ $expiresTime = new DateTime();
+ $accountData['token_expires'] = $expiresTime->setTimestamp($expires)->format('Y-m-d H:i:s');
+ } else {
+ $accountData['token_expires'] = null;
+ }
$accountData['data'] = serialize(Hash::get($data, 'raw'));
$accountData['active'] = true;
@@ -174,8 +179,6 @@ protected function _populateUser($data, $existingUser, $useEmail, $validateEmail
$userData['gender'] = Hash::get($data, 'gender');
//$userData['timezone'] = Hash::get($data, 'timezone');
$userData['social_accounts'][] = $accountData;
- debug($userData);
- die();
$user = $this->_table->newEntity($userData, ['associated' => ['SocialAccounts']]);
$user = $this->_updateActive($user, false, $tokenExpiration);
} else {
diff --git a/src/Model/Table/UsersTable.php b/src/Model/Table/UsersTable.php
index ca088f1e2..6ffbb2e47 100644
--- a/src/Model/Table/UsersTable.php
+++ b/src/Model/Table/UsersTable.php
@@ -44,7 +44,7 @@ public function initialize(array $config)
parent::initialize($config);
$this->table('users');
- $this->displayField('id');
+ $this->displayField('username');
$this->primaryKey('id');
$this->addBehavior('Timestamp');
$this->addBehavior('CakeDC/Users.Register');
diff --git a/src/Template/Users/login.ctp b/src/Template/Users/login.ctp
index 927287985..3ea2712fc 100644
--- a/src/Template/Users/login.ctp
+++ b/src/Template/Users/login.ctp
@@ -30,20 +30,26 @@ use Cake\Core\Configure;
?>
Html->link(__d('users', 'Register'), ['action' => 'register']);
}
- if (Configure::check('Users.Email.required')) {
- echo ' | ';
+ if (Configure::read('Users.Email.required')) {
+ if ($registrationActive) {
+ echo ' | ';
+ }
echo $this->Html->link(__d('users', 'Reset Password'), ['action' => 'requestResetPassword']);
}
?>
-
- = $this->User->facebookLogin(); ?>
- = $this->User->twitterLogin(); ?>
+
+
+ $options) : ?>
+
+ = $this->User->socialLogin($provider); ?>
+
+
= $this->Form->button(__d('Users', 'Login')); ?>
diff --git a/src/View/Helper/UserHelper.php b/src/View/Helper/UserHelper.php
index f1abb3417..1c5a18608 100644
--- a/src/View/Helper/UserHelper.php
+++ b/src/View/Helper/UserHelper.php
@@ -11,6 +11,7 @@
namespace CakeDC\Users\View\Helper;
+use Cake\Utility\Inflector;
use CakeDC\Users\Controller\Component\UsersAuthComponent;
use Cake\Core\Configure;
use Cake\Event\Event;
@@ -46,31 +47,19 @@ public function beforeLayout(Event $event)
}
/**
- * Facebook login link
+ * Social login link
*
+ * @param string $name
+ * @param array $options
* @return string
*/
- public function facebookLogin()
+ public function socialLogin($name, $options)
{
return $this->Html->link($this->Html->tag('i', '', [
- 'class' => 'fa fa-facebook'
- ]) . __d('Users', 'Sign in with Facebook'), '/auth/facebook', [
- 'escape' => false, 'class' => 'btn btn-social btn-facebook'
- ]);
- }
-
- /**
- * Twitter login link
- *
- * @return string
- */
- public function twitterLogin()
- {
- return $this->Html->link($this->Html->tag('i', '', [
- 'class' => 'fa fa-twitter'
- ]) . __d('Users', 'Sign in with Twitter'), '/auth/twitter', [
- 'escape' => false, 'class' => 'btn btn-social btn-twitter'
- ]);
+ 'class' => __d('Users', 'fa fa-{0}', strtolower($name)),
+ ]) . __d('Users', 'Sign in with {0}', Inflector::camelize($name)), "/auth/$name", [
+ 'escape' => false, 'class' => __d('Users', 'btn btn-social btn-{0} ' . $options['class'] ? :'', strtolower($name))
+ ]);
}
/**
From ebe01147523626958788520c695a62fc4bdd62dd Mon Sep 17 00:00:00 2001
From: Alejandro Ibarra
Date: Fri, 30 Oct 2015 20:44:27 -0500
Subject: [PATCH 0224/1397] Implement instagram/linkedin. Fix authenticate
---
config/bootstrap.php | 1 +
config/users.php | 6 +-
src/Auth/Social/Mapper/LinkedIn.php | 13 +++-
src/Auth/SocialAuthenticate.php | 51 +++++++++---
.../Component/RememberMeComponent.php | 2 +-
.../Component/UsersAuthComponent.php | 1 +
src/Controller/Traits/LoginTrait.php | 77 +++++++++++--------
src/Controller/Traits/SocialTrait.php | 10 +++
src/Controller/UsersController.php | 1 +
src/Model/Behavior/SocialBehavior.php | 25 +++---
src/Model/Table/UsersTable.php | 6 ++
src/Template/Users/social_email.ctp | 4 +-
12 files changed, 133 insertions(+), 64 deletions(-)
diff --git a/config/bootstrap.php b/config/bootstrap.php
index 19c9b5b6c..9efc06c3e 100644
--- a/config/bootstrap.php
+++ b/config/bootstrap.php
@@ -25,4 +25,5 @@
if (Configure::read('Users.Social.login')) {
Plugin::load('Muffin/OAuth2');
+ EventManager::instance()->on(\CakeDC\Users\Controller\Component\UsersAuthComponent::EVENT_FAILED_SOCIAL_LOGIN, [new \CakeDC\Users\Controller\UsersController(), 'failedSocialLogin']);
}
diff --git a/config/users.php b/config/users.php
index d96cd1bfa..57787a866 100644
--- a/config/users.php
+++ b/config/users.php
@@ -110,9 +110,9 @@
],
'linkedIn' => [
'className' => 'League\OAuth2\Client\Provider\LinkedIn',
- 'options' => [
- 'graphApiVersion' => 'v2.5'
- ]
+ ],
+ 'instagram' => [
+ 'className' => 'League\OAuth2\Client\Provider\Instagram',
]
],
]
diff --git a/src/Auth/Social/Mapper/LinkedIn.php b/src/Auth/Social/Mapper/LinkedIn.php
index 8d62ac3ca..934f2b1b7 100644
--- a/src/Auth/Social/Mapper/LinkedIn.php
+++ b/src/Auth/Social/Mapper/LinkedIn.php
@@ -11,5 +11,16 @@
class LinkedIn extends AbstractMapper
{
-
+ /**
+ * Map for provider fields
+ * @var
+ */
+ protected $_mapFields = [
+ 'avatar' => 'pictureUrl',
+ 'first_name' => 'firstName',
+ 'last_name' => 'lastName',
+ 'email' => 'emailAddress',
+ 'bio' => 'headline',
+ 'link' => 'publicProfileUrl'
+ ];
}
\ No newline at end of file
diff --git a/src/Auth/SocialAuthenticate.php b/src/Auth/SocialAuthenticate.php
index a7aca87fd..ca07a75cc 100755
--- a/src/Auth/SocialAuthenticate.php
+++ b/src/Auth/SocialAuthenticate.php
@@ -13,9 +13,15 @@
use Cake\Controller\ComponentRegistry;
use Cake\Core\Configure;
+use Cake\Error\Debugger;
+use Cake\Log\Log;
use Cake\Network\Request;
use Cake\ORM\TableRegistry;
use CakeDC\Users\Auth\Social\Util\SocialUtils;
+use CakeDC\Users\Controller\Component\UsersAuthComponent;
+use CakeDC\Users\Exception\AccountNotActiveException;
+use CakeDC\Users\Exception\MissingEmailException;
+use CakeDC\Users\Exception\UserNotActiveException;
use Muffin\OAuth2\Auth\OAuthAuthenticate;
/**
@@ -53,7 +59,25 @@ protected function _touch(array $data)
'validate_email' => Configure::read('Users.Email.validate'),
'token_expiration' => Configure::read('Users.Token.expiration')
];
- $user = $User->socialLogin($data, $options, $this->_provider);
+ try {
+ if (empty($data['provider']) && !empty($this->_provider)) {
+ $data['provider'] = SocialUtils::getProvider($this->_provider);
+ }
+ $user = $User->socialLogin($data, $options);
+ } catch (UserNotActiveException $ex) {
+ $exception = $ex;
+ } catch (AccountNotActiveException $ex) {
+ $exception = $ex;
+ } catch (MissingEmailException $ex) {
+ $exception = $ex;
+ }
+ if (!empty($exception)) {
+ $event = UsersAuthComponent::EVENT_FAILED_SOCIAL_LOGIN;
+ $args = ['exception' => $exception, 'rawData' => $data];
+ $event = $this->dispatchEvent($event, $args);
+ return $event->result;
+ }
+
if (!empty($user->username)) {
$user = $this->_findUser($user->username);
}
@@ -69,14 +93,23 @@ protected function _touch(array $data)
*/
public function getUser(Request $request)
{
- if (!$rawData = $this->_authenticate($request)) {
- return false;
- }
- $provider = SocialUtils::getProvider($this->_provider);
- $providerMapperClass = "\\CakeDC\\Users\\Auth\\Social\\Mapper\\$provider";
- $providerMapper = new $providerMapperClass($rawData);
- $user = $providerMapper();
+ $data = $request->session()->read(Configure::read('Users.Key.Session.social'));
+ if (!empty($data) && (!empty($data['email'] || !empty($request->data('email'))))) {
+ if (!empty($request->data('email'))) {
+ $data['email'] = $request->data('email');
+ }
+ $user = $data;
+ $request->session()->delete(Configure::read('Users.Key.Session.social'));
+ } else {
+ if (!$rawData = $this->_authenticate($request)) {
+ return false;
+ }
+ $provider = SocialUtils::getProvider($this->_provider);
+ $providerMapperClass = "\\CakeDC\\Users\\Auth\\Social\\Mapper\\$provider";
+ $providerMapper = new $providerMapperClass($rawData);
+ $user = $providerMapper();
+ }
if (!$user || !$this->config('userModel')) {
return false;
}
@@ -85,8 +118,6 @@ public function getUser(Request $request)
return false;
}
- $args = [$this->_provider, $result];
- $this->dispatchEvent('Muffin/OAuth2.afterIdentify', $args);
return $result;
}
}
diff --git a/src/Controller/Component/RememberMeComponent.php b/src/Controller/Component/RememberMeComponent.php
index 4f318abe1..1293b1ede 100644
--- a/src/Controller/Component/RememberMeComponent.php
+++ b/src/Controller/Component/RememberMeComponent.php
@@ -133,7 +133,7 @@ public function destroy(Event $event)
public function beforeFilter(Event $event)
{
$user = $this->Auth->user();
- if (!empty($user) || $this->request->is(['post', 'put']) || $this->request->action === 'logout' || $this->request->session()->check(Configure::read('Users.Key.Session.social'))) {
+ if (!empty($user) || $this->request->is(['post', 'put']) || $this->request->action === 'logout' || $this->request->session()->check(Configure::read('Users.Key.Session.social')) || $this->request->param('provider')) {
return;
}
diff --git a/src/Controller/Component/UsersAuthComponent.php b/src/Controller/Component/UsersAuthComponent.php
index b9b32a314..f46092a67 100644
--- a/src/Controller/Component/UsersAuthComponent.php
+++ b/src/Controller/Component/UsersAuthComponent.php
@@ -24,6 +24,7 @@ class UsersAuthComponent extends Component
const EVENT_IS_AUTHORIZED = 'Users.Component.UsersAuth.isAuthorized';
const EVENT_BEFORE_LOGIN = 'Users.Component.UsersAuth.beforeLogin';
const EVENT_AFTER_LOGIN = 'Users.Component.UsersAuth.afterLogin';
+ const EVENT_FAILED_SOCIAL_LOGIN = 'Users.Component.UsersAuth.failedSocialLogin';
const EVENT_AFTER_COOKIE_LOGIN = 'Users.Component.UsersAuth.afterCookieLogin';
const EVENT_BEFORE_REGISTER = 'Users.Component.UsersAuth.beforeRegister';
const EVENT_AFTER_REGISTER = 'Users.Component.UsersAuth.afterRegister';
diff --git a/src/Controller/Traits/LoginTrait.php b/src/Controller/Traits/LoginTrait.php
index fd1200574..380509fc7 100644
--- a/src/Controller/Traits/LoginTrait.php
+++ b/src/Controller/Traits/LoginTrait.php
@@ -11,11 +11,14 @@
namespace CakeDC\Users\Controller\Traits;
+use Cake\Event\Event;
+use Cake\Network\Exception\NotFoundException;
use CakeDC\Users\Controller\Component\UsersAuthComponent;
use CakeDC\Users\Exception\AccountNotActiveException;
use CakeDC\Users\Exception\MissingEmailException;
use Cake\Core\Configure;
use Cake\Utility\Hash;
+use CakeDC\Users\Exception\UserNotActiveException;
/**
* Covers the login, logout and social login
@@ -25,8 +28,37 @@ trait LoginTrait
{
use CustomUsersTableTrait;
+ /**
+ * @param $event
+ */
+ public function failedSocialLogin($event) {
+ if ($event->data['exception'] instanceof MissingEmailException) {
+ $this->Flash->success(__d('Users', 'Please enter your email'));
+ $this->request->session()->write(Configure::read('Users.Key.Session.social'), $event->data['rawData']);
+ return $this->redirect(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'socialEmail']);
+ }
+ if ($event->data['exception'] instanceof UserNotActiveException) {
+ $msg = __d('Users', 'Your user has not been validated yet. Please check your inbox for instructions');
+ } elseif ($event->data['exception'] instanceof AccountNotActiveException) {
+ $msg = __d('Users', 'Your social account has not been validated yet. Please check your inbox for instructions');
+ }
+ $this->Flash->success($msg);
+ return $this->redirect(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login']);
+ }
+
+ /**
+ * @return array
+ */
public function socialLogin()
{
+ $socialProvider = $this->request->param('provider');
+ $socialUser = $this->request->session()->read(Configure::read('Users.Key.Session.social'));
+
+ if (empty($socialProvider) && empty($socialUser)) {
+ throw new NotFoundException();
+ }
+ $user = $this->Auth->user();
+ return $this->_afterIdentifyUser($user, true);
}
/**
@@ -43,21 +75,14 @@ public function login()
if ($event->isStopped()) {
return $this->redirect($event->result);
}
- $socialLogin = $this->_isSocialLogin();
- if (!$this->request->is('post') && !$socialLogin) {
- return;
+ $socialLogin = $this->request->session()->check(Configure::read('Users.Key.Session.social'));
+ if (!empty($socialLogin)) {
+ $this->redirect(['action' => 'social-email']);
}
-
- try {
+ if ($this->request->is('post')) {
$user = $this->Auth->identify();
- return $this->_afterIdentifyUser($user, $socialLogin);
- } catch (AccountNotActiveException $ex) {
- $msg = __d('Users', 'Your social account has not been validated yet. Please check your inbox for instructions');
- $this->Flash->success($msg);
- } catch (MissingEmailException $ex) {
- $this->Flash->success(__d('Users', 'Please enter your email'));
- return $this->redirect(['controller' => 'Users', 'action' => 'socialEmail']);
+ return $this->_afterIdentifyUser($user, false);
}
}
@@ -69,36 +94,22 @@ public function login()
*/
protected function _afterIdentifyUser($user, $socialLogin = false)
{
- $socialKey = Configure::read('Users.Key.Session.social');
if (!empty($user)) {
- $this->request->session()->delete($socialKey);
$this->Auth->setUser($user);
- $event = $this->dispatchEvent(UsersAuthComponent::EVENT_AFTER_LOGIN);
+
+ $event = $this->dispatchEvent(UsersAuthComponent::EVENT_AFTER_LOGIN, ['user' => $user]);
if (is_array($event->result)) {
return $this->redirect($event->result);
}
$url = $this->Auth->redirectUrl();
return $this->redirect($url);
} else {
- $message = __d('Users', 'Username or password is incorrect');
- if ($socialLogin) {
- $socialData = $this->request->session()->read($socialKey);
- $socialDataEmail = null;
- if (!empty($socialData->info)) {
- $socialDataEmail = Hash::get((array)$socialData->info, Configure::read('data_email_key'));
- }
- $postedEmail = $this->request->data(Configure::read('Users.Key.Data.email'));
- if (Configure::read('Users.Email.required') &&
- empty($socialDataEmail) &&
- empty($postedEmail)) {
- return $this->redirect([
- 'controller' => 'Users',
- 'action' => 'socialEmail'
- ]);
- }
- $message = __d('Users', 'There was an error associating your social network account');
+ if (!$socialLogin) {
+ $message = __d('Users', 'Username or password is incorrect');
+ $this->Flash->error($message, 'default', [], 'auth');
}
- $this->Flash->error($message, 'default', [], 'auth');
+
+ $this->redirect($this->Auth->redirectUrl());
}
}
diff --git a/src/Controller/Traits/SocialTrait.php b/src/Controller/Traits/SocialTrait.php
index ecb5bba72..bb03f187b 100644
--- a/src/Controller/Traits/SocialTrait.php
+++ b/src/Controller/Traits/SocialTrait.php
@@ -31,5 +31,15 @@ public function socialEmail()
if (!$this->request->session()->check(Configure::read('Users.Key.Session.social'))) {
throw new NotFoundException();
}
+
+ if ($this->request->is('post')) {
+ $validPost = $this->_validateRegisterPost();
+ if (!$validPost) {
+ $this->Flash->error(__d('Users', 'The reCaptcha could not be validated'));
+ return;
+ }
+ $user = $this->Auth->identify();
+ return $this->_afterIdentifyUser($user, true);
+ }
}
}
diff --git a/src/Controller/UsersController.php b/src/Controller/UsersController.php
index a0337b31a..45cd15827 100644
--- a/src/Controller/UsersController.php
+++ b/src/Controller/UsersController.php
@@ -12,6 +12,7 @@
namespace CakeDC\Users\Controller;
use CakeDC\Users\Controller\AppController;
+use CakeDC\Users\Controller\Component\UsersAuthComponent;
use CakeDC\Users\Controller\Traits\LoginTrait;
use CakeDC\Users\Controller\Traits\ProfileTrait;
use CakeDC\Users\Controller\Traits\RegisterTrait;
diff --git a/src/Model/Behavior/SocialBehavior.php b/src/Model/Behavior/SocialBehavior.php
index 91d6e4b30..528069415 100644
--- a/src/Model/Behavior/SocialBehavior.php
+++ b/src/Model/Behavior/SocialBehavior.php
@@ -11,21 +11,15 @@
namespace CakeDC\Users\Model\Behavior;
-use Cake\Event\Event;
use Cake\Event\EventDispatcherTrait;
-use CakeDC\Users\Auth\Social\Util\SocialUtils;
use CakeDC\Users\Exception\AccountNotActiveException;
use CakeDC\Users\Exception\MissingEmailException;
-use CakeDC\Users\Model\Behavior\Behavior;
-use CakeDC\Users\Model\Table\SocialAccountsTable;
+use CakeDC\Users\Exception\UserNotActiveException;
use CakeDC\Users\Traits\RandomStringTrait;
use Cake\Datasource\EntityInterface;
use Cake\Utility\Hash;
use DateTime;
use InvalidArgumentException;
-use League\OAuth2\Client\Provider\AbstractProvider;
-use League\OAuth2\Client\Provider\Facebook;
-use ReflectionClass;
/**
* Covers social features
@@ -41,21 +35,16 @@ class SocialBehavior extends Behavior
*
* @param array $data Array social login.
* @param array $options Array option data.
- * @param AbstractProvider $provider Provider
* @return bool|EntityInterface|mixed
*/
- public function socialLogin(array $data, array $options, AbstractProvider $provider)
+ public function socialLogin(array $data, array $options)
{
- $data['provider'] = SocialUtils::getProvider($provider);
$reference = Hash::get($data, 'id');
$existingAccount = $this->_table->SocialAccounts->find()
->where(['SocialAccounts.reference' => $reference, 'SocialAccounts.provider' => $data['provider']])
->contain(['Users'])
->first();
if (empty($existingAccount->user)) {
- $event = 'Muffin/OAuth2.newUser';
- $args = [$provider, $data];
- $this->dispatchEvent($event, $args);
$user = $this->_createSocialUser($data, $options);
if (!empty($user->social_accounts[0])) {
$existingAccount = $user->social_accounts[0];
@@ -68,7 +57,15 @@ public function socialLogin(array $data, array $options, AbstractProvider $provi
}
if (!empty($existingAccount)) {
if ($existingAccount->active) {
- return $user;
+ if ($user->active) {
+ return $user;
+ } else {
+ throw new UserNotActiveException([
+ $existingAccount->provider,
+ $existingAccount->$user
+ ]);
+ }
+
} else {
throw new AccountNotActiveException([
$existingAccount->provider,
diff --git a/src/Model/Table/UsersTable.php b/src/Model/Table/UsersTable.php
index 6ffbb2e47..984628e5d 100644
--- a/src/Model/Table/UsersTable.php
+++ b/src/Model/Table/UsersTable.php
@@ -26,6 +26,12 @@
class UsersTable extends Table
{
+ /**
+ * Role Constants
+ */
+ const ROLE_USER = 'user';
+ const ROLE_ADMIN = 'admin';
+
/**
* Flag to set email check in buildRules or not
*
diff --git a/src/Template/Users/social_email.ctp b/src/Template/Users/social_email.ctp
index c2e29be82..52cc6086e 100644
--- a/src/Template/Users/social_email.ctp
+++ b/src/Template/Users/social_email.ctp
@@ -10,8 +10,8 @@
*/
?>
From b7abe9b58e398f89908c1afb85cb9f2e8335bbcc Mon Sep 17 00:00:00 2001
From: Alejandro Ibarra
Date: Fri, 4 Dec 2015 12:45:40 -0500
Subject: [PATCH 0249/1397] Finish twitter implementation. Fix Instagram login
---
composer.json | 3 +-
src/Auth/Social/Mapper/AbstractMapper.php | 8 +--
src/Auth/Social/Mapper/Instagram.php | 6 +-
src/Auth/Social/Mapper/Twitter.php | 16 +++++
src/Auth/SocialAuthenticate.php | 5 +-
src/Controller/Traits/LoginTrait.php | 85 ++++++++++++-----------
src/Model/Behavior/SocialBehavior.php | 5 +-
src/Model/Entity/User.php | 1 +
8 files changed, 73 insertions(+), 56 deletions(-)
diff --git a/composer.json b/composer.json
index a3bd60a99..a4700bcee 100644
--- a/composer.json
+++ b/composer.json
@@ -22,7 +22,8 @@
},
"autoload-dev": {
"psr-4": {
- "CakeDC\\Users\\Test\\": "tests"
+ "CakeDC\\Users\\Test\\": "tests",
+ "CakeDC\\Users\\Test\\Fixture": "tests"
}
}
}
diff --git a/src/Auth/Social/Mapper/AbstractMapper.php b/src/Auth/Social/Mapper/AbstractMapper.php
index f5febe6b4..b0706507f 100644
--- a/src/Auth/Social/Mapper/AbstractMapper.php
+++ b/src/Auth/Social/Mapper/AbstractMapper.php
@@ -90,11 +90,11 @@ protected function _map()
}
$result[$field] = $value;
});
- $token = (array)Hash::get($this->_rawData, 'token');
+ $token = Hash::get($this->_rawData, 'token');
$result['credentials'] = [
- 'token' => Hash::get($token, 'accessToken'),
- 'secret' => Hash::get($token, 'tokenSecret'),
- 'expires' => Hash::get($token, 'expires'),
+ 'token' => is_array($token) ? Hash::get($token, 'accessToken') : $token->getToken(),
+ 'secret' => is_array($token) ? Hash::get($token, 'tokenSecret') : null,
+ 'expires' => is_array($token) ? Hash::get($token, 'expires') : $token->getExpires(),
];
$result['raw'] = $this->_rawData;
return $result;
diff --git a/src/Auth/Social/Mapper/Instagram.php b/src/Auth/Social/Mapper/Instagram.php
index c483c551e..0c89d26a3 100644
--- a/src/Auth/Social/Mapper/Instagram.php
+++ b/src/Auth/Social/Mapper/Instagram.php
@@ -22,10 +22,8 @@ class Instagram extends AbstractMapper
* @var
*/
protected $_mapFields = [
- 'avatar' => 'data.profile_picture',
- 'id' => 'data.id',
- 'full_name' => 'data.full_name',
- 'username' => 'data.username'
+ 'full_name' => 'full_name',
+ 'avatar' => 'profile_picture',
];
/**
diff --git a/src/Auth/Social/Mapper/Twitter.php b/src/Auth/Social/Mapper/Twitter.php
index 639190ab8..1fa6ad471 100644
--- a/src/Auth/Social/Mapper/Twitter.php
+++ b/src/Auth/Social/Mapper/Twitter.php
@@ -9,8 +9,16 @@
namespace CakeDC\Users\Auth\Social\Mapper;
+use Cake\Utility\Hash;
+
class Twitter extends AbstractMapper
{
+
+ /**
+ * Url constants
+ */
+ const TWITTER_BASE_URL = 'https://twitter.com/';
+
/**
* Map for provider fields
* @var null
@@ -26,4 +34,12 @@ class Twitter extends AbstractMapper
'bio' => 'description',
'validated' => 'validated'
];
+
+ /**
+ * @return string
+ */
+ protected function _link()
+ {
+ return self::TWITTER_BASE_URL . Hash::get($this->_rawData, $this->_mapFields['username']);
+ }
}
\ No newline at end of file
diff --git a/src/Auth/SocialAuthenticate.php b/src/Auth/SocialAuthenticate.php
index 1d8023db1..7c42c56b2 100755
--- a/src/Auth/SocialAuthenticate.php
+++ b/src/Auth/SocialAuthenticate.php
@@ -64,7 +64,8 @@ protected function _touch(array $data)
if (empty($data['provider']) && !empty($this->_provider)) {
$data['provider'] = SocialUtils::getProvider($this->_provider);
}
- $user = $User->socialLogin($data, $options);
+
+ $user = $User->socialLogin($data, $options);
} catch (UserNotActiveException $ex) {
$exception = $ex;
} catch (AccountNotActiveException $ex) {
@@ -77,7 +78,7 @@ protected function _touch(array $data)
$event = UsersAuthComponent::EVENT_FAILED_SOCIAL_LOGIN;
$args = ['exception' => $exception, 'rawData' => $data];
$event = $this->dispatchEvent($event, $args);
- if ($data['provider'] == SocialAccountsTable::PROVIDER_TWITTER) {
+ if ($exception instanceof MissingEmailException && $data['provider'] == SocialAccountsTable::PROVIDER_TWITTER) {
throw $exception;
}
return $event->result;
diff --git a/src/Controller/Traits/LoginTrait.php b/src/Controller/Traits/LoginTrait.php
index 48b27fc88..caf05066d 100644
--- a/src/Controller/Traits/LoginTrait.php
+++ b/src/Controller/Traits/LoginTrait.php
@@ -31,66 +31,66 @@ trait LoginTrait
public function twitterLogin() {
$this->autoRender = false;
- $server = new Twitter(array(
- 'identifier' => 'ZqU9nNUsyuRkDJRLvPYPQ9YXI',
- 'secret' => 'vZrxSe5c7DKEUROMpTUDjPu2Mepvvzucsk1ZSSYluRiNB4H5qN',
- 'callbackUri' => 'http://local.woozk.xyz/auth/twitter',
- ));
-// $oauthToken = $this->request->query('oauth_token');
-// $oauthVerifier = $this->request->query('oauth_verifier');
-// if (!empty($oauthToken) && !empty($oauthVerifier)) {
+
+ $server = new Twitter([
+ 'identifier' => Configure::read('OAuth.providers.twitter.options.identifier'),
+ 'secret' => Configure::read('OAuth.providers.twitter.options.secret'),
+ 'callbackUri' => Configure::read('OAuth.providers.twitter.options.redirectUri'),
+ ]);
+ $oauthToken = $this->request->query('oauth_token');
+ $oauthVerifier = $this->request->query('oauth_verifier');
+ if (!empty($oauthToken) && !empty($oauthVerifier)) {
$temporaryCredentials = $this->request->session()->read('temporary_credentials');
- //$tokenCredentials = $server->getTokenCredentials($temporaryCredentials, $oauthToken, $oauthVerifier);
- $tokenCredentials = new \League\OAuth1\Client\Credentials\TokenCredentials();
- $tokenCredentials->setIdentifier('2165382168-o3THZG14a5t21k4CdkCmGhecu2MrZpPNx6rpflm');
- $tokenCredentials->setSecret('sX0CMhCzoaUPxlachfdAItdrkZAgltk5xy0Djbl1hfXaP');
- $user = (array)$server->getUserDetails($tokenCredentials);
- $user['token'] = [
- 'accessToken' => $tokenCredentials->getIdentifier(),
- 'tokenSecret' => $tokenCredentials->getSecret(),
- ];
- $this->request->session()->write(Configure::read('Users.Key.Session.social'), $user);
- try {
- $user = $this->Auth->identify();
- $this->_afterIdentifyUser($user, true);
- } catch (UserNotActiveException $ex) {
- $exception = $ex;
- } catch (AccountNotActiveException $ex) {
- $exception = $ex;
- } catch (MissingEmailException $ex) {
- $exception = $ex;
- }
- if (!empty($exception)) {
- return $this->failedSocialLogin($exception, $this->request->session()->read(Configure::read('Users.Key.Session.social')));
- }
-// } else {
-// $temporaryCredentials = $server->getTemporaryCredentials();
-// $this->request->session()->write('temporary_credentials', $temporaryCredentials);
-// $server->authorize($temporaryCredentials);
-// }
+ $tokenCredentials = $server->getTokenCredentials($temporaryCredentials, $oauthToken, $oauthVerifier);
+ $user = (array)$server->getUserDetails($tokenCredentials);
+ $user['token'] = [
+ 'accessToken' => $tokenCredentials->getIdentifier(),
+ 'tokenSecret' => $tokenCredentials->getSecret(),
+ ];
+ $this->request->session()->write(Configure::read('Users.Key.Session.social'), $user);
+ try {
+ $user = $this->Auth->identify();
+ $this->_afterIdentifyUser($user, true);
+ } catch (UserNotActiveException $ex) {
+ $exception = $ex;
+ } catch (AccountNotActiveException $ex) {
+ $exception = $ex;
+ } catch (MissingEmailException $ex) {
+ $exception = $ex;
+ }
+ if (!empty($exception)) {
+ return $this->failedSocialLogin($exception, $this->request->session()->read(Configure::read('Users.Key.Session.social')));
+ }
+ } else {
+ $temporaryCredentials = $server->getTemporaryCredentials();
+ $this->request->session()->write('temporary_credentials', $temporaryCredentials);
+ $server->authorize($temporaryCredentials);
+ }
return;
}
/**
* @param $event
*/
public function failedSocialLoginListener(Event $event) {
- $this->failedSocialLogin($event->data['exception'], $event->data['rawData']);
+ $this->failedSocialLogin($event->data['exception'], $event->data['rawData'], true);
}
/**
* @param $exception
* @param $data
+ * @param bool|false $flash
* @return mixed
*/
- public function failedSocialLogin($exception, $data)
+ public function failedSocialLogin($exception, $data, $flash = false)
{
$msg = __d('Users', 'Issues trying to log in with your social account');
if (isset($exception) ) {
if ($exception instanceof MissingEmailException) {
- $this->Flash->success(__d('Users', 'Please enter your email'));
+ if ($flash) {
+ $this->Flash->success(__d('Users', 'Please enter your email'));
+ }
$this->request->session()->write(Configure::read('Users.Key.Session.social'), $data);
return $this->redirect(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'socialEmail']);
-
}
if ($exception instanceof UserNotActiveException) {
$msg = __d('Users', 'Your user has not been validated yet. Please check your inbox for instructions');
@@ -98,7 +98,10 @@ public function failedSocialLogin($exception, $data)
$msg = __d('Users', 'Your social account has not been validated yet. Please check your inbox for instructions');
}
}
- $this->Flash->success($msg);
+ if ($flash) {
+ $this->request->session()->delete(Configure::read('Users.Key.Session.social'));
+ $this->Flash->success($msg);
+ }
return $this->redirect(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login']);
}
diff --git a/src/Model/Behavior/SocialBehavior.php b/src/Model/Behavior/SocialBehavior.php
index 02c1c69e3..e939c2f94 100644
--- a/src/Model/Behavior/SocialBehavior.php
+++ b/src/Model/Behavior/SocialBehavior.php
@@ -45,11 +45,7 @@ public function socialLogin(array $data, array $options)
->contain(['Users'])
->first();
if (empty($existingAccount->user)) {
- debug($data);
- debug($options);
$user = $this->_createSocialUser($data, $options);
- debug($user);
- die();
if (!empty($user->social_accounts[0])) {
$existingAccount = $user->social_accounts[0];
} else {
@@ -101,6 +97,7 @@ protected function _createSocialUser($data, $options = [])
->where([$this->_table->alias() . '.email' => $email])
->first();
}
+
$user = $this->_populateUser($data, $existingUser, $useEmail, $validateEmail, $tokenExpiration);
$this->_table->isValidateEmail = $validateEmail;
$result = $this->_table->save($user);
diff --git a/src/Model/Entity/User.php b/src/Model/Entity/User.php
index f33b5e51d..4e588032f 100644
--- a/src/Model/Entity/User.php
+++ b/src/Model/Entity/User.php
@@ -35,6 +35,7 @@ class User extends Entity
'confirm_password' => true,
'first_name' => true,
'last_name' => true,
+ 'avatar' => true,
'token' => true,
'token_expires' => true,
'api_token' => true,
From f7ab5c42cac2cdd3f61d0b475b707bd509036a76 Mon Sep 17 00:00:00 2001
From: Yelitza Parra
Date: Mon, 14 Dec 2015 11:19:16 -0430
Subject: [PATCH 0250/1397] Fixing unit tests after twitter integration changes
---
config/bootstrap.php | 12 ++-
src/Model/Behavior/RegisterBehavior.php | 1 +
.../Controller/Traits/LoginTraitTest.php | 98 +++++++++----------
.../Model/Behavior/RegisterBehaviorTest.php | 5 -
4 files changed, 59 insertions(+), 57 deletions(-)
diff --git a/config/bootstrap.php b/config/bootstrap.php
index 38e79e6fa..28400af47 100644
--- a/config/bootstrap.php
+++ b/config/bootstrap.php
@@ -10,6 +10,8 @@
*/
use Cake\Core\Configure;
+use Cake\Log\Log;
+use Cake\Core\Exception\MissingPluginException;
use Cake\Core\Plugin;
use Cake\Event\EventManager;
use Cake\ORM\TableRegistry;
@@ -23,7 +25,11 @@
Configure::write('Auth.authenticate.all.userModel', Configure::read('Users.table'));
}
-if (Configure::read('Users.Social.login')) {
- Plugin::load('Muffin/OAuth2');
- EventManager::instance()->on(\CakeDC\Users\Controller\Component\UsersAuthComponent::EVENT_FAILED_SOCIAL_LOGIN, [new \CakeDC\Users\Controller\UsersController(), 'failedSocialLoginListener']);
+if (Configure::read('Users.Social.login') && php_sapi_name() != 'cli') {
+ try {
+ Plugin::load('Muffin/OAuth2');
+ EventManager::instance()->on(\CakeDC\Users\Controller\Component\UsersAuthComponent::EVENT_FAILED_SOCIAL_LOGIN, [new \CakeDC\Users\Controller\UsersController(), 'failedSocialLoginListener']);
+ } catch (MissingPluginException $e) {
+ Log::error($e->getMessage());
+ }
}
diff --git a/src/Model/Behavior/RegisterBehavior.php b/src/Model/Behavior/RegisterBehavior.php
index 87b4a77f1..3d065f7fe 100644
--- a/src/Model/Behavior/RegisterBehavior.php
+++ b/src/Model/Behavior/RegisterBehavior.php
@@ -109,6 +109,7 @@ public function activateUser(EntityInterface $user)
throw new UserAlreadyActiveException(__d('Users', "User account already validated"));
}
$user->activation_date = new DateTime();
+ $user->token_expires = null;
$user->active = true;
$result = $this->_table->save($user);
diff --git a/tests/TestCase/Controller/Traits/LoginTraitTest.php b/tests/TestCase/Controller/Traits/LoginTraitTest.php
index a3255fb4c..a8c1e12e3 100644
--- a/tests/TestCase/Controller/Traits/LoginTraitTest.php
+++ b/tests/TestCase/Controller/Traits/LoginTraitTest.php
@@ -62,12 +62,12 @@ public function testLoginHappy()
{
$this->_mockDispatchEvent(new Event('event'));
$this->Trait->request = $this->getMockBuilder('Cake\Network\Request')
- ->setMethods(['is'])
- ->getMock();
+ ->setMethods(['is'])
+ ->getMock();
$this->Trait->request->expects($this->once())
- ->method('is')
- ->with('post')
- ->will($this->returnValue(true));
+ ->method('is')
+ ->with('post')
+ ->will($this->returnValue(true));
$this->Trait->Auth = $this->getMockBuilder('Cake\Controller\Component\AuthComponent')
->setMethods(['user', 'identify', 'setUser', 'redirectUrl'])
->disableOriginalConstructor()
@@ -80,14 +80,14 @@ public function testLoginHappy()
->method('identify')
->will($this->returnValue($user));
$this->Trait->Auth->expects($this->at(1))
- ->method('setUser')
- ->with($user);
+ ->method('setUser')
+ ->with($user);
$this->Trait->Auth->expects($this->at(2))
->method('redirectUrl')
->will($this->returnValue($redirectLoginOK));
$this->Trait->expects($this->once())
- ->method('redirect')
- ->with($redirectLoginOK);
+ ->method('redirect')
+ ->with($redirectLoginOK);
$this->Trait->login();
}
@@ -100,12 +100,12 @@ public function testAfterIdentifyEmptyUser()
{
$this->_mockDispatchEvent(new Event('event'));
$this->Trait->request = $this->getMockBuilder('Cake\Network\Request')
- ->setMethods(['is'])
- ->getMock();
+ ->setMethods(['is'])
+ ->getMock();
$this->Trait->request->expects($this->once())
- ->method('is')
- ->with('post')
- ->will($this->returnValue(true));
+ ->method('is')
+ ->with('post')
+ ->will($this->returnValue(true));
$this->Trait->Auth = $this->getMockBuilder('Cake\Controller\Component\AuthComponent')
->setMethods(['user', 'identify', 'setUser', 'redirectUrl'])
->disableOriginalConstructor()
@@ -119,8 +119,8 @@ public function testAfterIdentifyEmptyUser()
->disableOriginalConstructor()
->getMock();
$this->Trait->Flash->expects($this->once())
- ->method('error')
- ->with('Username or password is incorrect', 'default', [], 'auth');
+ ->method('error')
+ ->with('Username or password is incorrect', 'default', [], 'auth');
$this->Trait->login();
}
@@ -135,12 +135,12 @@ public function testAfterIdentifyEmptyUserSocialLogin()
->setMethods(['dispatchEvent', 'redirect', '_isSocialLogin'])
->getMockForTrait();
$this->Trait->expects($this->any())
- ->method('_isSocialLogin')
- ->will($this->returnValue(true));
+ ->method('_isSocialLogin')
+ ->will($this->returnValue(true));
$this->_mockDispatchEvent(new Event('event'));
$this->Trait->request = $this->getMockBuilder('Cake\Network\Request')
- ->setMethods(['is'])
- ->getMock();
+ ->setMethods(['is'])
+ ->getMock();
/*$this->Trait->request->expects($this->once())
->method('is')
->with('post')
@@ -150,9 +150,9 @@ public function testAfterIdentifyEmptyUserSocialLogin()
->disableOriginalConstructor()
->getMock();
$user = [];
- /* $this->Trait->Auth->expects($this->once())
- ->method('identify')
- ->will($this->returnValue($user));*/
+ /* $this->Trait->Auth->expects($this->once())
+ ->method('identify')
+ ->will($this->returnValue($user));*/
$this->Trait->expects($this->once())
->method('redirect')
@@ -176,27 +176,27 @@ public function testLoginBeforeLoginReturningArray()
$event = new Event('event');
$event->result = $user;
$this->Trait->expects($this->at(0))
- ->method('dispatchEvent')
- ->with(UsersAuthComponent::EVENT_BEFORE_LOGIN)
- ->will($this->returnValue($event));
+ ->method('dispatchEvent')
+ ->with(UsersAuthComponent::EVENT_BEFORE_LOGIN)
+ ->will($this->returnValue($event));
$this->Trait->expects($this->at(1))
- ->method('dispatchEvent')
- ->with(UsersAuthComponent::EVENT_AFTER_LOGIN)
- ->will($this->returnValue(new Event('name')));
+ ->method('dispatchEvent')
+ ->with(UsersAuthComponent::EVENT_AFTER_LOGIN)
+ ->will($this->returnValue(new Event('name')));
$this->Trait->Auth = $this->getMockBuilder('Cake\Controller\Component\AuthComponent')
->setMethods(['setUser', 'redirectUrl'])
->disableOriginalConstructor()
->getMock();
$redirectLoginOK = '/';
$this->Trait->Auth->expects($this->once())
- ->method('setUser')
- ->with($user);
+ ->method('setUser')
+ ->with($user);
$this->Trait->Auth->expects($this->once())
->method('redirectUrl')
->will($this->returnValue($redirectLoginOK));
$this->Trait->expects($this->once())
- ->method('redirect')
- ->with($redirectLoginOK);
+ ->method('redirect')
+ ->with($redirectLoginOK);
$this->Trait->login();
}
@@ -211,12 +211,12 @@ public function testLoginBeforeLoginReturningStoppedEvent()
$event->result = '/';
$event->stopPropagation();
$this->Trait->expects($this->at(0))
- ->method('dispatchEvent')
- ->with(UsersAuthComponent::EVENT_BEFORE_LOGIN)
- ->will($this->returnValue($event));
+ ->method('dispatchEvent')
+ ->with(UsersAuthComponent::EVENT_BEFORE_LOGIN)
+ ->will($this->returnValue($event));
$this->Trait->expects($this->once())
- ->method('redirect')
- ->with('/');
+ ->method('redirect')
+ ->with('/');
$this->Trait->login();
}
@@ -235,9 +235,9 @@ public function testLoginGet()
->disableOriginalConstructor()
->getMock();
$this->Trait->request->expects($this->once())
- ->method('is')
- ->with('post')
- ->will($this->returnValue(false));
+ ->method('is')
+ ->with('post')
+ ->will($this->returnValue(false));
$this->Trait->login();
Configure::write('Users.Social.login', $socialLogin);
}
@@ -259,15 +259,15 @@ public function testLogout()
->method('logout')
->will($this->returnValue($redirectLogoutOK));
$this->Trait->expects($this->once())
- ->method('redirect')
- ->with($redirectLogoutOK);
+ ->method('redirect')
+ ->with($redirectLogoutOK);
$this->Trait->Flash = $this->getMockBuilder('Cake\Controller\Component\FlashComponent')
->setMethods(['success'])
->disableOriginalConstructor()
->getMock();
$this->Trait->Flash->expects($this->once())
- ->method('success')
- ->with('You\'ve successfully logged out');
+ ->method('success')
+ ->with('You\'ve successfully logged out');
$this->Trait->logout();
}
@@ -296,7 +296,7 @@ public function testFailedSocialLoginMissingEmail()
->method('redirect')
->with(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'socialEmail']);
- $this->Trait->failedSocialLogin($event);
+ $this->Trait->failedSocialLogin($event->data['exception'], $event->data['rawData'], true);
}
/**
@@ -324,7 +324,7 @@ public function testFailedSocialUserNotActive()
->method('redirect')
->with(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login']);
- $this->Trait->failedSocialLogin($event);
+ $this->Trait->failedSocialLogin($event->data['exception'], $event->data['rawData'], true);
}
/**
@@ -352,7 +352,7 @@ public function testFailedSocialUserAccountNotActive()
->method('redirect')
->with(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login']);
- $this->Trait->failedSocialLogin($event);
+ $this->Trait->failedSocialLogin($event->data['exception'], $event->data['rawData'], true);
}
@@ -380,6 +380,6 @@ public function testFailedSocialUserAccount()
->method('redirect')
->with(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login']);
- $this->Trait->failedSocialLogin($event);
+ $this->Trait->failedSocialLogin(null, $event->data['rawData'], true);
}
}
diff --git a/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php b/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php
index 5148525ce..e6d3657b3 100644
--- a/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php
+++ b/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php
@@ -255,7 +255,6 @@ public function testActiveUserRemoveValidationToken()
{
$user = $this->Table->find()->where(['id' => '00000000-0000-0000-0000-000000000001'])->first();
$this->Behavior = $this->getMockBuilder('CakeDC\Users\Model\Behavior\RegisterBehavior')
- ->setMethods(['_removeValidationToken'])
->setConstructorArgs([$this->Table])
->getMock();
@@ -263,10 +262,6 @@ public function testActiveUserRemoveValidationToken()
$resultValidationToken->token_expires = null;
$resultValidationToken->token = null;
- $this->Behavior->expects($this->once())
- ->method('_removeValidationToken')
- ->will($this->returnValue($resultValidationToken));
-
$this->Behavior->activateUser($user);
}
}
From f4377331d76d66a40e6348c4a93c880f9acfbb2a Mon Sep 17 00:00:00 2001
From: designway
Date: Mon, 4 Jan 2016 14:25:53 +0100
Subject: [PATCH 0251/1397] Update AbstractMapper.php
Social login by google, validate/active fields are always false.
AbstractMapper.php the function _validated return false because email field is returned in a array.
'emails' => [
(int) 0 => [
'value' => '...@...'
]
And mapFields['email'] for google is emails.0.value, cant use !empty() for that.
---
src/Auth/Social/Mapper/AbstractMapper.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Auth/Social/Mapper/AbstractMapper.php b/src/Auth/Social/Mapper/AbstractMapper.php
index b0706507f..590a9fc84 100644
--- a/src/Auth/Social/Mapper/AbstractMapper.php
+++ b/src/Auth/Social/Mapper/AbstractMapper.php
@@ -71,7 +71,7 @@ public function __invoke()
*/
protected function _validated()
{
- return !empty($this->_rawData[$this->_mapFields['email']]);
+ return !empty(Hash::get($this->_rawData, $this->_mapFields['email']));
}
/**
From 1937249a10c82f79228c5db36de0d7ffd432e51e Mon Sep 17 00:00:00 2001
From: Pedro Fernandes Steimbruch
Date: Wed, 6 Jan 2016 18:50:03 -0200
Subject: [PATCH 0252/1397] fixing composer.json Fixture namespace
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index a4700bcee..4fe069456 100644
--- a/composer.json
+++ b/composer.json
@@ -23,7 +23,7 @@
"autoload-dev": {
"psr-4": {
"CakeDC\\Users\\Test\\": "tests",
- "CakeDC\\Users\\Test\\Fixture": "tests"
+ "CakeDC\\Users\\Test\\Fixture\\": "tests"
}
}
}
From 3748afd11639fdda0c56db1b139f931426e5713f Mon Sep 17 00:00:00 2001
From: Pedro Fernandes Steimbruch
Date: Wed, 6 Jan 2016 19:21:02 -0200
Subject: [PATCH 0253/1397] fixing User::tokenExpired method
---
src/Model/Entity/User.php | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/Model/Entity/User.php b/src/Model/Entity/User.php
index 4e588032f..6dcbbd3e9 100644
--- a/src/Model/Entity/User.php
+++ b/src/Model/Entity/User.php
@@ -125,7 +125,12 @@ public function checkPassword($password, $hashedPassword)
*/
public function tokenExpired()
{
- return empty($this->token_expires) || strtotime($this->token_expires) < strtotime("now");
+ if (empty($this->token_expires)) {
+ return true;
+ }
+
+ $tokenExpiresTime = strtotime($this->token_expires->format("Y-m-d H:i"));
+ return $tokenExpiresTime < strtotime("now");
}
/**
From 9435f7bd29a40542651b00bf523cef61cf5eaa8e Mon Sep 17 00:00:00 2001
From: Pedro Fernandes Steimbruch
Date: Wed, 6 Jan 2016 19:29:17 -0200
Subject: [PATCH 0254/1397] fixing User::tokenExpired method when token_expires
is string
---
src/Model/Entity/User.php | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/Model/Entity/User.php b/src/Model/Entity/User.php
index 6dcbbd3e9..14a9b6426 100644
--- a/src/Model/Entity/User.php
+++ b/src/Model/Entity/User.php
@@ -129,8 +129,12 @@ public function tokenExpired()
return true;
}
- $tokenExpiresTime = strtotime($this->token_expires->format("Y-m-d H:i"));
- return $tokenExpiresTime < strtotime("now");
+ $tokenExpiresTime = $this->token_expires;
+ if (is_object($this->token_expires)) {
+ $tokenExpiresTime = $this->token_expires->format("Y-m-d H:i");
+ }
+
+ return strtotime($tokenExpiresTime) < strtotime("now");
}
/**
From 64bcb3ad56d10a62f5d598bd51e0f2bb9d9696ac Mon Sep 17 00:00:00 2001
From: chav170
Date: Sun, 10 Jan 2016 16:41:29 +0000
Subject: [PATCH 0255/1397] refs #validation-messages-fix now the validation
errors from patchEntity are displayed on the change password form
---
src/Controller/Traits/PasswordManagementTrait.php | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/Controller/Traits/PasswordManagementTrait.php b/src/Controller/Traits/PasswordManagementTrait.php
index ed6008da7..b7045ce57 100644
--- a/src/Controller/Traits/PasswordManagementTrait.php
+++ b/src/Controller/Traits/PasswordManagementTrait.php
@@ -48,12 +48,16 @@ public function changePassword()
if ($this->request->is('post')) {
try {
$user = $this->getUsersTable()->patchEntity($user, $this->request->data(), ['validate' => 'passwordConfirm']);
- $user = $this->getUsersTable()->changePassword($user);
- if ($user) {
- $this->Flash->success(__d('Users', 'Password has been changed successfully'));
- return $this->redirect($redirect);
- } else {
+ if ($user->errors()) {
$this->Flash->error(__d('Users', 'Password could not be changed'));
+ } else {
+ $user = $this->getUsersTable()->changePassword($user);
+ if ($user) {
+ $this->Flash->success(__d('Users', 'Password has been changed successfully'));
+ return $this->redirect($redirect);
+ } else {
+ $this->Flash->error(__d('Users', 'Password could not be changed'));
+ }
}
} catch (UserNotFoundException $exception) {
$this->Flash->error(__d('Users', 'User was not found'));
From dfa62299dfc2465c6612c97f6e4a41355c133ac6 Mon Sep 17 00:00:00 2001
From: chav170
Date: Sun, 10 Jan 2016 16:50:12 +0000
Subject: [PATCH 0256/1397] refs #validation-messages-fix fixed double
validation error message per field email and username
---
src/Model/Table/UsersTable.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Model/Table/UsersTable.php b/src/Model/Table/UsersTable.php
index ca088f1e2..f36a9b3e1 100644
--- a/src/Model/Table/UsersTable.php
+++ b/src/Model/Table/UsersTable.php
@@ -151,13 +151,13 @@ public function validationRegister(Validator $validator)
*/
public function buildRules(RulesChecker $rules)
{
- $rules->add($rules->isUnique(['username']), [
+ $rules->add($rules->isUnique(['username']), '_isUnique', [
'errorField' => 'username',
'message' => __d('Users', 'Username already exists')
]);
if ($this->isValidateEmail) {
- $rules->add($rules->isUnique(['email']), [
+ $rules->add($rules->isUnique(['email']), '_isUnique', [
'errorField' => 'email',
'message' => __d('Users', 'Email already exists')
]);
From 6693068ecedd3b664e971191916a4b14abe36e5b Mon Sep 17 00:00:00 2001
From: Ayman Alkom
Date: Wed, 13 Jan 2016 12:10:10 +0200
Subject: [PATCH 0257/1397] Update LoginTrait.php
---
src/Controller/Traits/LoginTrait.php | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/Controller/Traits/LoginTrait.php b/src/Controller/Traits/LoginTrait.php
index afde464af..984dd09db 100644
--- a/src/Controller/Traits/LoginTrait.php
+++ b/src/Controller/Traits/LoginTrait.php
@@ -42,6 +42,11 @@ public function login()
$socialLogin = $this->_isSocialLogin();
if (!$this->request->is('post') && !$socialLogin) {
+ if ($this->Auth->user()) {
+ $msg = __d('Users', 'Your are already logged in');
+ $this->Flash->error($msg);
+ return $this->redirect($this->referer());
+ }
return;
}
From 0aebf2ec17b8877eaffec7df3442a28cb78378f8 Mon Sep 17 00:00:00 2001
From: Ayman Alkom
Date: Thu, 14 Jan 2016 14:03:20 +0200
Subject: [PATCH 0258/1397] Update LoginTraitTest.php
---
tests/TestCase/Controller/Traits/LoginTraitTest.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tests/TestCase/Controller/Traits/LoginTraitTest.php b/tests/TestCase/Controller/Traits/LoginTraitTest.php
index 88bac68f5..5af8f865f 100644
--- a/tests/TestCase/Controller/Traits/LoginTraitTest.php
+++ b/tests/TestCase/Controller/Traits/LoginTraitTest.php
@@ -326,6 +326,10 @@ public function testLoginGet()
$this->_mockDispatchEvent(new Event('event'));
$socialLogin = Configure::read('Users.Social.login');
Configure::write('Users.Social.login', false);
+ $this->Trait->Auth = $this->getMockBuilder('Cake\Controller\Component\AuthComponent')
+ ->setMethods(['user'])
+ ->disableOriginalConstructor()
+ ->getMock();
$this->Trait->request = $this->getMockBuilder('Cake\Network\Request')
->setMethods(['is'])
->disableOriginalConstructor()
From 97cf2e0eb66329f3d2ab5e30a268777def4c37f2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20M=2E=20Gonz=C3=A1lez=20Mart=C3=ADn?=
Date: Thu, 14 Jan 2016 13:05:41 +0000
Subject: [PATCH 0259/1397] update php version for coveralls
---
.travis.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index b9669e624..cc347134b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -20,10 +20,10 @@ matrix:
fast_finish: true
include:
- - php: 5.4
+ - php: 5.5
env: PHPCS=1 DEFAULT=0
- - php: 5.4
+ - php: 5.5
env: COVERALLS=1 DEFAULT=0 DB=mysql db_dsn='mysql://travis@0.0.0.0/cakephp_test'
before_script:
From 5ed0a325edf0069f56d61c204a3b1f4a6e948f76 Mon Sep 17 00:00:00 2001
From: Yelitza Parra
Date: Wed, 20 Jan 2016 19:29:39 -0430
Subject: [PATCH 0260/1397] Adding unit tests to SocialAuthenticate,
SocialBehavior and UsersHelper. Refactoring where needed
---
src/Auth/SocialAuthenticate.php | 75 ++-
src/Exception/MissingProviderException.php | 18 +
src/Model/Behavior/SocialBehavior.php | 6 +-
src/View/Helper/UserHelper.php | 5 +-
.../TestCase/Auth/SocialAuthenticateTest.php | 484 ++++++++++++++++++
.../Model/Behavior/SocialBehaviorTest.php | 363 +++++++++++++
tests/TestCase/Shell/UsersShellTest.php | 24 +-
tests/TestCase/View/Helper/UserHelperTest.php | 25 +
8 files changed, 973 insertions(+), 27 deletions(-)
create mode 100644 src/Exception/MissingProviderException.php
create mode 100644 tests/TestCase/Auth/SocialAuthenticateTest.php
create mode 100644 tests/TestCase/Model/Behavior/SocialBehaviorTest.php
diff --git a/src/Auth/SocialAuthenticate.php b/src/Auth/SocialAuthenticate.php
index 7c42c56b2..29c43ba85 100755
--- a/src/Auth/SocialAuthenticate.php
+++ b/src/Auth/SocialAuthenticate.php
@@ -21,6 +21,7 @@
use CakeDC\Users\Controller\Component\UsersAuthComponent;
use CakeDC\Users\Exception\AccountNotActiveException;
use CakeDC\Users\Exception\MissingEmailException;
+use CakeDC\Users\Exception\MissingProviderException;
use CakeDC\Users\Exception\UserNotActiveException;
use CakeDC\Users\Model\Table\SocialAccountsTable;
use Muffin\OAuth2\Auth\OAuthAuthenticate;
@@ -50,22 +51,15 @@ public function __construct(ComponentRegistry $registry, array $config = [])
* Find or create local user
* @param array $data
* @return array|bool|mixed
+ * @throws MissingEmailException
*/
protected function _touch(array $data)
{
- $userModel = Configure::read('Users.table');
- $User = TableRegistry::get($userModel);
- $options = [
- 'use_email' => Configure::read('Users.Email.required'),
- 'validate_email' => Configure::read('Users.Email.validate'),
- 'token_expiration' => Configure::read('Users.Token.expiration')
- ];
try {
if (empty($data['provider']) && !empty($this->_provider)) {
$data['provider'] = SocialUtils::getProvider($this->_provider);
}
-
- $user = $User->socialLogin($data, $options);
+ $user = $this->_socialLogin($data);
} catch (UserNotActiveException $ex) {
$exception = $ex;
} catch (AccountNotActiveException $ex) {
@@ -113,16 +107,9 @@ public function getUser(Request $request)
if (empty($rawData)) {
$rawData = $data;
}
- if (!is_null($this->_provider)) {
- $provider = SocialUtils::getProvider($this->_provider);
- } else {
- $provider = ucfirst($request->param('provider'));
- }
- $providerMapperClass = "\\CakeDC\\Users\\Auth\\Social\\Mapper\\$provider";
- $providerMapper = new $providerMapperClass($rawData);
- $user = $providerMapper();
- $user['provider'] = $provider;
+ $provider = $this->_getProviderName($request);
+ $user = $this->_mapUser($provider, $rawData);
}
if (!$user || !$this->config('userModel')) {
@@ -132,7 +119,57 @@ public function getUser(Request $request)
if (!$result = $this->_touch($user)) {
return false;
}
-
return $result;
}
+
+ /**
+ * Get the provider name based on the request or on the provider set.
+ *
+ * @param \Cake\Network\Request $request Request object.
+ * @return mixed Either false or an array of user information
+ */
+ protected function _getProviderName($request = null)
+ {
+ $provider = false;
+ if (!is_null($this->_provider)) {
+ $provider = SocialUtils::getProvider($this->_provider);
+ } else if (!empty($request)){
+ $provider = ucfirst($request->param('provider'));
+ }
+ return $provider;
+ }
+
+ /**
+ * Get the provider name based on the request or on the provider set.
+ *
+ * @param string $provider Provider name.
+ * @param array $data User data
+ * @throws MissingProviderException
+ * @return mixed Either false or an array of user information
+ */
+ protected function _mapUser($provider, $data)
+ {
+ if (empty($provider)) {
+ throw new MissingProviderException(__d('Users', "Provider cannot be empty"));
+ }
+ $providerMapperClass = "\\CakeDC\\Users\\Auth\\Social\\Mapper\\$provider";
+ $providerMapper = new $providerMapperClass($data);
+ $user = $providerMapper();
+ $user['provider'] = $provider;
+ return $user;
+ }
+
+ protected function _socialLogin($data)
+ {
+ $options = [
+ 'use_email' => Configure::read('Users.Email.required'),
+ 'validate_email' => Configure::read('Users.Email.validate'),
+ 'token_expiration' => Configure::read('Users.Token.expiration')
+ ];
+
+ $userModel = Configure::read('Users.table');
+ $User = TableRegistry::get($userModel);
+ $user = $User->socialLogin($data, $options);
+ return $user;
+ }
}
diff --git a/src/Exception/MissingProviderException.php b/src/Exception/MissingProviderException.php
new file mode 100644
index 000000000..dc25ed0e8
--- /dev/null
+++ b/src/Exception/MissingProviderException.php
@@ -0,0 +1,18 @@
+generateUniqueUsername(Hash::get($userData, 'username'));
-
if ($useEmail) {
$userData['email'] = Hash::get($data, 'email');
if (empty(Hash::get($data, 'validated'))) {
$accountData['active'] = false;
}
}
+
$userData['password'] = $this->randomString();
$userData['avatar'] = Hash::get($data, 'avatar');
$userData['validated'] = !empty(Hash::get($data, 'validated'));
- $userData['tos_date'] = date("Y-m-d H:i:s");
+ $userData['tos_date'] = date("Y-m-d H:i:s");
$userData['gender'] = Hash::get($data, 'gender');
//$userData['timezone'] = Hash::get($data, 'timezone');
$userData['social_accounts'][] = $accountData;
diff --git a/src/View/Helper/UserHelper.php b/src/View/Helper/UserHelper.php
index 8bb4a3a14..1dd5a4e7e 100644
--- a/src/View/Helper/UserHelper.php
+++ b/src/View/Helper/UserHelper.php
@@ -11,11 +11,11 @@
namespace CakeDC\Users\View\Helper;
-use Cake\Utility\Inflector;
use CakeDC\Users\Controller\Component\UsersAuthComponent;
use Cake\Core\Configure;
use Cake\Event\Event;
use Cake\Utility\Hash;
+use Cake\Utility\Inflector;
use Cake\View\Helper;
/**
@@ -133,9 +133,10 @@ public function addReCaptchaScript()
*/
public function addReCaptcha()
{
- if (!Configure::check('Users.Registration.reCaptcha')) {
+ if (!Configure::read('Users.Registration.reCaptcha')) {
return false;
}
+
$this->Form->unlockField('g-recaptcha-response');
return $this->Html->tag('div', '', [
'class' => 'g-recaptcha',
diff --git a/tests/TestCase/Auth/SocialAuthenticateTest.php b/tests/TestCase/Auth/SocialAuthenticateTest.php
new file mode 100644
index 000000000..cbdb3c9c2
--- /dev/null
+++ b/tests/TestCase/Auth/SocialAuthenticateTest.php
@@ -0,0 +1,484 @@
+Table = TableRegistry::get('CakeDC/Users.Users');
+
+ $this->Token = $this->getMockBuilder('AccessToken')
+ ->setMethods(['getToken', 'getExpires'])
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->controller = $this->getMock(
+ 'Cake\Controller\Controller',
+ null,
+ [$request, $response]
+ );
+ $this->Request = $request;
+ $this->Registry = new ComponentRegistry($this->controller);
+
+ $this->SocialAuthenticate = $this->getMockBuilder('CakeDC\Users\Auth\SocialAuthenticate')
+ ->setMethods(['_authenticate', '_getProviderName', '_mapUser', '_socialLogin', 'dispatchEvent'])
+ ->disableOriginalConstructor()
+ ->getMock();
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ public function tearDown()
+ {
+ unset($this->SocialAuthenticate, $this->controller);
+ }
+
+ /**
+ * Test getUser
+ *
+ * @dataProvider providerGetUser
+ */
+ public function testGetUserAuth($rawData, $mapper)
+ {
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_authenticate')
+ ->with($this->Request)
+ ->will($this->returnValue($rawData));
+
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_getProviderName')
+ ->will($this->returnValue('facebook'));
+
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_mapUser')
+ ->will($this->returnValue($mapper));
+
+ $user = $this->Table->get('00000000-0000-0000-0000-000000000002');
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_socialLogin')
+ ->will($this->returnValue($user));
+
+
+ $result = $this->SocialAuthenticate->getUser($this->Request);
+ $this->assertTrue($result['active']);
+ $this->assertEquals('00000000-0000-0000-0000-000000000002', $result['id']);
+ }
+
+ /**
+ * Provider for getUser test method
+ *
+ */
+ public function providerGetUser()
+ {
+ return [
+ [
+ 'rawData' => [
+ 'token' => 'token',
+ 'id' => 'reference-2-1',
+ 'name' => 'User S',
+ 'first_name' => 'user',
+ 'last_name' => 'second',
+ 'email' => 'userSecond@example.com',
+ 'cover' => [
+ 'id' => 'reference-2-1'
+ ],
+ 'gender' => 'female',
+ 'locale' => 'en_US',
+ 'link' => 'link',
+ ],
+ 'mappedData' => [
+ 'id' => 'reference-2-1',
+ 'username' => null,
+ 'full_name' => 'User S',
+ 'first_name' => 'user',
+ 'last_name' => 'second',
+ 'email' => 'userSecond@example.com',
+ 'link' => 'link',
+ 'bio' => null,
+ 'locale' => 'en_US',
+ 'validated' => true,
+ 'credentials' => [
+ 'token' => 'token',
+ 'secret' => null,
+ 'expires' => 1458423682
+ ],
+ 'raw' => [
+
+ ],
+ 'provider' => 'Facebook'
+ ],
+ ]
+
+ ];
+ }
+
+ /**
+ * Test getUser
+ *
+ */
+ public function testGetUserSessionData()
+ {
+ $user = ['username' => 'username', 'email' => 'myemail@test.com'];
+ $this->SocialAuthenticate = $this->getMockBuilder('CakeDC\Users\Auth\SocialAuthenticate')
+ ->setMethods(['_authenticate', '_getProviderName', '_mapUser', '_touch'])
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $session = $this->getMock('Cake\Network\Session', ['read', 'delete']);
+ $session->expects($this->once())
+ ->method('read')
+ ->with('Users.social')
+ ->will($this->returnValue($user));
+
+ $session->expects($this->once())
+ ->method('delete')
+ ->with('Users.social');
+
+ $this->Request = $this->getMock('Cake\Network\Request', ['session']);
+ $this->Request->expects($this->any())
+ ->method('session')
+ ->will($this->returnValue($session));
+
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_touch')
+ ->will($this->returnValue($user));
+
+ $this->SocialAuthenticate->getUser($this->Request);
+ }
+
+ /**
+ * Test getUser
+ *
+ * @dataProvider providerGetUser
+ */
+ public function testGetUserNotEmailProvided($rawData, $mapper)
+ {
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_authenticate')
+ ->with($this->Request)
+ ->will($this->returnValue($rawData));
+
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_getProviderName')
+ ->will($this->returnValue('facebook'));
+
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_mapUser')
+ ->will($this->returnValue($mapper));
+
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_socialLogin')
+ ->will($this->throwException(new MissingEmailException('missing email')));
+
+ $event = new Event('ExceptionEvent');
+ $event->result = 'result';
+
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('dispatchEvent')
+ ->will($this->returnValue($event));
+
+ $result = $this->SocialAuthenticate->getUser($this->Request);
+ $this->assertEquals($result, 'result');
+ }
+
+ /**
+ * Test getUser
+ *
+ * @dataProvider providerGetUser
+ */
+ public function testGetUserNotActive($rawData, $mapper)
+ {
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_authenticate')
+ ->with($this->Request)
+ ->will($this->returnValue($rawData));
+
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_getProviderName')
+ ->will($this->returnValue('facebook'));
+
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_mapUser')
+ ->will($this->returnValue($mapper));
+
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_socialLogin')
+ ->will($this->throwException(new UserNotActiveException('user not active')));
+
+ $event = new Event('ExceptionEvent');
+ $event->result = 'result';
+
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('dispatchEvent')
+ ->will($this->returnValue($event));
+
+ $result = $this->SocialAuthenticate->getUser($this->Request);
+ $this->assertEquals($result, 'result');
+ }
+
+ /**
+ * Test getUser
+ *
+ * @dataProvider providerGetUser
+ */
+ public function testGetUserNotActiveAccount($rawData, $mapper)
+ {
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_authenticate')
+ ->with($this->Request)
+ ->will($this->returnValue($rawData));
+
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_getProviderName')
+ ->will($this->returnValue('facebook'));
+
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_mapUser')
+ ->will($this->returnValue($mapper));
+
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_socialLogin')
+ ->will($this->throwException(new AccountNotActiveException('user not active')));
+
+ $event = new Event('ExceptionEvent');
+ $event->result = 'result';
+
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('dispatchEvent')
+ ->will($this->returnValue($event));
+
+ $result = $this->SocialAuthenticate->getUser($this->Request);
+ $this->assertEquals($result, 'result');
+ }
+
+ /**
+ * Test getUser
+ *
+ * @dataProvider providerTwitter
+ * @expectedException CakeDC\Users\Exception\MissingEmailException
+ */
+ public function testGetUserNotEmailProvidedTwitter($rawData, $mapper)
+ {
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_authenticate')
+ ->with($this->Request)
+ ->will($this->returnValue($rawData));
+
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_getProviderName')
+ ->will($this->returnValue('twitter'));
+
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_mapUser')
+ ->will($this->returnValue($mapper));
+
+ $this->SocialAuthenticate->expects($this->once())
+ ->method('_socialLogin')
+ ->will($this->throwException(new MissingEmailException('missing email')));
+
+ $this->SocialAuthenticate->getUser($this->Request);
+ }
+
+ /**
+ * Provider for getUser test method
+ *
+ */
+ public function providerTwitter()
+ {
+ return [
+ [
+ 'rawData' => [
+ 'token' => 'token',
+ 'id' => 'reference-2-1',
+ 'name' => 'User S',
+ 'first_name' => 'user',
+ 'last_name' => 'second',
+ 'email' => 'userSecond@example.com',
+ 'cover' => [
+ 'id' => 'reference-2-1'
+ ],
+ 'gender' => 'female',
+ 'locale' => 'en_US',
+ 'link' => 'link',
+ ],
+ 'mappedData' => [
+ 'id' => 'reference-2-1',
+ 'username' => null,
+ 'full_name' => 'User S',
+ 'first_name' => 'user',
+ 'last_name' => 'second',
+ 'email' => 'userSecond@example.com',
+ 'link' => 'link',
+ 'bio' => null,
+ 'locale' => 'en_US',
+ 'validated' => true,
+ 'credentials' => [
+ 'token' => 'token',
+ 'secret' => null,
+ 'expires' => 1458423682
+ ],
+ 'raw' => [
+
+ ],
+ 'provider' => 'Twitter'
+ ],
+ ]
+
+ ];
+ }
+
+ /**
+ * Test _socialLogin
+ *
+ * @dataProvider providerMapper
+ */
+ public function testSocialLogin()
+ {
+ $this->SocialAuthenticate = $this->getMockBuilder('CakeDC\Users\Auth\SocialAuthenticate')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $reflectedClass = new ReflectionClass($this->SocialAuthenticate);
+ $socialLogin = $reflectedClass->getMethod('_socialLogin');
+ $socialLogin->setAccessible(true);
+ $data = [
+ 'id' => 'reference-2-1',
+ 'provider' => 'Facebook'
+ ];
+ $result = $socialLogin->invoke($this->SocialAuthenticate, $data);
+ $this->assertEquals($result->id, '00000000-0000-0000-0000-000000000002');
+ $this->assertTrue($result->active);
+ }
+
+ /**
+ * Test _mapUser
+ *
+ * @dataProvider providerMapper
+ */
+ public function testMapUser($data, $mappedData)
+ {
+ $data['token'] = $this->Token;
+ $this->SocialAuthenticate = $this->getMockBuilder('CakeDC\Users\Auth\SocialAuthenticate')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $reflectedClass = new ReflectionClass($this->SocialAuthenticate);
+ $mapUser = $reflectedClass->getMethod('_mapUser');
+ $mapUser->setAccessible(true);
+
+ $this->Token->expects($this->once())
+ ->method('getToken')
+ ->will($this->returnValue('token'));
+
+ $this->Token->expects($this->once())
+ ->method('getExpires')
+ ->will($this->returnValue(1458510952));
+
+ $result = $mapUser->invoke($this->SocialAuthenticate, 'Facebook', $data);
+ unset($result['raw']);
+ $this->assertEquals($result, $mappedData);
+ }
+
+ /**
+ * Provider for _mapUser test method
+ *
+ */
+ public function providerMapper()
+ {
+ return [
+ [
+ 'rawData' => [
+ 'id' => 'my-facebook-id',
+ 'name' => 'My name.',
+ 'first_name' => 'My first name',
+ 'last_name' => 'My lastname.',
+ 'email' => 'myemail@example.com',
+ 'gender' => 'female',
+ 'locale' => 'en_US',
+ 'link' => 'https://www.facebook.com/app_scoped_user_id/my-facebook-id/',
+ ],
+ 'mappedData' => [
+ 'id' => 'my-facebook-id',
+ 'username' => null,
+ 'full_name' => 'My name.',
+ 'first_name' => 'My first name',
+ 'last_name' => 'My lastname.',
+ 'email' => 'myemail@example.com',
+ 'avatar' => 'https://graph.facebook.com/my-facebook-id/picture?type=normal',
+ 'gender' => 'female',
+ 'link' => 'https://www.facebook.com/app_scoped_user_id/my-facebook-id/',
+ 'bio' => null,
+ 'locale' => 'en_US',
+ 'validated' => true,
+ 'credentials' => [
+ 'token' => 'token',
+ 'secret' => null,
+ 'expires' => (int) 1458510952
+ ],
+ 'provider' => 'Facebook'
+ ],
+ ]
+
+ ];
+ }
+
+ /**
+ * Test _mapUser
+ *
+ * @expectedException CakeDC\Users\Exception\MissingProviderException
+ */
+ public function testMapUserException()
+ {
+ $data = [];
+ $this->SocialAuthenticate = $this->getMockBuilder('CakeDC\Users\Auth\SocialAuthenticate')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $reflectedClass = new ReflectionClass($this->SocialAuthenticate);
+ $mapUser = $reflectedClass->getMethod('_mapUser');
+ $mapUser->setAccessible(true);
+ $mapUser->invoke($this->SocialAuthenticate, null, $data);
+ }
+
+}
diff --git a/tests/TestCase/Model/Behavior/SocialBehaviorTest.php b/tests/TestCase/Model/Behavior/SocialBehaviorTest.php
new file mode 100644
index 000000000..83cbb908a
--- /dev/null
+++ b/tests/TestCase/Model/Behavior/SocialBehaviorTest.php
@@ -0,0 +1,363 @@
+Table = $this->getMockForModel('CakeDC/Users.Users', ['save']);
+ $this->Behavior = $this->getMockBuilder('CakeDC\Users\Model\Behavior\SocialBehavior')
+ ->setMethods(['randomString', '_updateActive', 'generateUniqueUsername'])
+ ->setConstructorArgs([$this->Table])
+ ->getMock();
+ }
+
+ /**
+ * tearDown
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ unset($this->Table, $this->Behavior, $this->Email);
+ parent::tearDown();
+ }
+
+ /**
+ * Test socialLogin with facebook and not existing user
+ *
+ * @dataProvider providerFacebookSocialLogin
+ */
+ public function testSocialLoginFacebookProvider($data, $options, $dataUser)
+ {
+ $user = $this->Table->newEntity($dataUser, ['associated' => ['SocialAccounts']]);
+ $user->password = '$2y$10$0QzszaIEpW1pYpoKJVf4DeqEAHtg9whiLTX/l3TcHAoOLF1bC9U.6';
+
+ $this->Behavior->expects($this->once())
+ ->method('generateUniqueUsername')
+ ->with('email')
+ ->will($this->returnValue('username'));
+
+ $this->Behavior->expects($this->once())
+ ->method('randomString')
+ ->will($this->returnValue('password'));
+
+ $this->Behavior->expects($this->once())
+ ->method('_updateActive')
+ ->will($this->returnValue($user));
+
+ $this->Table->expects($this->once())
+ ->method('save')
+ ->with($user)
+ ->will($this->returnValue($user));
+
+ $result = $this->Behavior->socialLogin($data, $options);
+ $this->assertEquals($result, $user);
+ }
+
+ /**
+ * Provider for socialLogin with facebook and not existing user
+ *
+ */
+ public function providerFacebookSocialLogin()
+ {
+ return [
+ 'provider' => [
+ 'data' => [
+ 'id' => 'facebook-id',
+ 'username' => null,
+ 'full_name' => 'Full name',
+ 'first_name' => 'First name',
+ 'last_name' => 'Last name',
+ 'email' => 'email@example.com',
+ 'raw' => [
+ 'id' => '10153521527396318',
+ 'name' => 'Ful Name.',
+ 'first_name' => 'First Name',
+ 'last_name' => 'Last name',
+ 'email' => 'email@example.com',
+ 'picture' => [
+ 'data' => [
+ 'url' => 'data-url'
+ ]
+ ]
+ ],
+ 'credentials' => [
+ 'token' => 'token',
+ 'secret' => null,
+ 'expires' => 1458423682
+ ],
+ 'validated' => true,
+ 'link' => 'facebook-link',
+ 'provider' => 'Facebook'
+ ],
+ 'options' => [
+ 'use_email' => true,
+ 'validate_email' => true,
+ 'token_expiration' => 3600
+ ],
+ 'result' => [
+ 'first_name' => 'First name',
+ 'last_name' => 'Last name',
+ 'username' => 'username',
+ 'email' => 'email@example.com',
+ 'password' => '$2y$10$oLPxCkKJ1TUCR6xJ1t0Wj.7Fznx49Wn4NZB2aJCmVvRMucaHuNyyO',
+ 'avatar' => null,
+ 'tos_date' => '2016-01-20 15:45:09',
+ 'gender' => null,
+ 'social_accounts' => [
+ [
+ 'provider' => 'Facebook',
+ 'username' => null,
+ 'reference' => '10153521527396318',
+ 'avatar' => '',
+ 'link' => 'facebook-link',
+ 'description' => null,
+ 'token' => 'token',
+ 'token_secret' => null,
+ 'token_expires' => '2016-03-19 21:41:22',
+ 'data' => '-',
+ 'active' => true
+ ]
+ ],
+ 'activation_date' => '2016-01-20 15:45:09',
+ 'active' => true,
+ ]
+ ]
+
+ ];
+
+ }
+
+ /**
+ * Test socialLogin with facebook with existing and active user
+ *
+ * @dataProvider providerFacebookSocialLoginExistingReference
+ */
+ public function testSocialLoginExistingReference($data, $options)
+ {
+ $this->Behavior->expects($this->never())
+ ->method('generateUniqueUsername');
+
+ $this->Behavior->expects($this->never())
+ ->method('randomString');
+
+ $this->Behavior->expects($this->never())
+ ->method('_updateActive');
+
+ $result = $this->Behavior->socialLogin($data, $options);
+ $this->assertEquals($result->id, '00000000-0000-0000-0000-000000000002');
+ $this->assertTrue($result->active);
+
+ }
+
+ /**
+ * Provider for socialLogin with facebook with existing and active user
+ *
+ */
+ public function providerFacebookSocialLoginExistingReference()
+ {
+ return [
+ 'provider' => [
+ 'data' => [
+ 'id' => 'reference-2-1',
+ 'provider' => 'Facebook'
+ ],
+ 'options' => [
+ 'use_email' => true,
+ 'validate_email' => true,
+ 'token_expiration' => 3600
+ ],
+ ]
+
+ ];
+ }
+
+ /**
+ * Test socialLogin with existing and active user and not active social account
+ *
+ * @expectedException CakeDC\Users\Exception\AccountNotActiveException
+ * @dataProvider providerSocialLoginExistingAndNotActiveAccount
+ */
+ public function testSocialLoginExistingNotActiveReference($data, $options)
+ {
+
+ $this->Behavior->expects($this->never())
+ ->method('generateUniqueUsername');
+
+ $this->Behavior->expects($this->never())
+ ->method('randomString');
+
+ $this->Behavior->expects($this->never())
+ ->method('_updateActive');
+ $this->Behavior->socialLogin($data, $options);
+
+ }
+
+ /**
+ * Provider for socialLogin with existing and active user and not active social account
+ *
+ */
+ public function providerSocialLoginExistingAndNotActiveAccount()
+ {
+ return [
+ 'provider' => [
+ 'data' => [
+ 'id' => 'reference-1-1234',
+ 'provider' => 'Facebook'
+ ],
+ 'options' => [
+ 'use_email' => true,
+ 'validate_email' => true,
+ 'token_expiration' => 3600
+ ],
+ ]
+
+ ];
+ }
+
+ /**
+ * Test socialLogin with existing and active account but not active user
+ *
+ * @expectedException CakeDC\Users\Exception\UserNotActiveException
+ * @dataProvider providerSocialLoginExistingAccountNotActiveUser
+ */
+ public function testSocialLoginExistingReferenceNotActiveUser($data, $options)
+ {
+
+ $this->Behavior->expects($this->never())
+ ->method('generateUniqueUsername');
+
+ $this->Behavior->expects($this->never())
+ ->method('randomString');
+
+ $this->Behavior->expects($this->never())
+ ->method('_updateActive');
+ $this->Behavior->socialLogin($data, $options);
+
+ }
+
+ /**
+ * Provider for socialLogin with existing and active account but not active user
+ *
+ */
+ public function providerSocialLoginExistingAccountNotActiveUser()
+ {
+ return [
+ 'provider' => [
+ 'data' => [
+ 'id' => 'reference-1-1234',
+ 'provider' => 'Twitter'
+ ],
+ 'options' => [
+ 'use_email' => true,
+ 'validate_email' => true,
+ 'token_expiration' => 3600
+ ],
+ ]
+
+ ];
+ }
+
+ /**
+ * Test socialLogin with facebook and not existing user
+ *
+ * @dataProvider providerFacebookSocialLoginNoEmail
+ * @expectedException CakeDC\Users\Exception\MissingEmailException
+ */
+ public function testSocialLoginNoEmail($data, $options)
+ {
+ $result = $this->Behavior->socialLogin($data, $options);
+ }
+
+
+ /**
+ * Provider for socialLogin with facebook and not existing user
+ *
+ */
+ public function providerFacebookSocialLoginNoEmail()
+ {
+ return [
+ 'provider' => [
+ 'data' => [
+ 'id' => 'facebook-id',
+ 'username' => null,
+ 'full_name' => 'Full name',
+ 'first_name' => 'First name',
+ 'last_name' => 'Last name',
+ 'validated' => true,
+ 'link' => 'facebook-link',
+ 'provider' => 'Facebook'
+ ],
+ 'options' => [
+ 'use_email' => true,
+ 'validate_email' => true,
+ 'token_expiration' => 3600
+ ],
+ ]
+
+ ];
+ }
+
+ /**
+ * Test socialLogin with facebook and not existing user
+ *
+ * @dataProvider providerGenerateUsername
+ */
+ public function testGenerateUniqueUsername($param, $expected)
+ {
+ $this->Behavior = $this->getMockBuilder('CakeDC\Users\Model\Behavior\SocialBehavior')
+ ->setMethods(['randomString', '_updateActive'])
+ ->setConstructorArgs([$this->Table])
+ ->getMock();
+
+ $result = $this->Behavior->generateUniqueUsername($param);
+ $this->assertEquals($expected, $result);
+ }
+
+ /**
+ * Provider for socialLogin with facebook and not existing user
+ *
+ */
+ public function providerGenerateUsername()
+ {
+ return [
+ ['username', 'username'],
+ ['user-1', 'user-10'],
+ ['user-5', 'user-50']
+
+ ];
+ }
+
+}
diff --git a/tests/TestCase/Shell/UsersShellTest.php b/tests/TestCase/Shell/UsersShellTest.php
index 2980a2dce..f773beb99 100644
--- a/tests/TestCase/Shell/UsersShellTest.php
+++ b/tests/TestCase/Shell/UsersShellTest.php
@@ -36,12 +36,12 @@ public function setUp()
{
parent::setUp();
$this->out = new ConsoleOutput();
- $this->io = new ConsoleIo($this->out);
+ $this->io = $this->getMock('Cake\Console\ConsoleIo');
$this->Users = TableRegistry::get('CakeDC/Users.Users');
$this->Shell = $this->getMockBuilder('CakeDC\Users\Shell\UsersShell')
->setMethods(['in', 'out', '_stop', 'clear', '_usernameSeed', '_generateRandomPassword',
- '_generateRandomUsername', '_generatedHashedPassword', 'error'])
+ '_generateRandomUsername', '_generatedHashedPassword', 'error', '_updateUser'])
->setConstructorArgs([$this->io])
->getMock();
@@ -108,8 +108,6 @@ public function testAddUser()
->with($entityUser)
->will($this->returnValue($userSaved));
- //TODO: Add assertions with 'out'
-
$this->Shell->runCommand(['addUser', '--username=' . $user['username'], '--password=' . $user['password'], '--email=' . $user['email']]);
}
@@ -234,4 +232,22 @@ public function testResetAllPasswordsNoPassingParams()
$this->Shell->runCommand(['resetAllPasswords']);
}
+
+ /**
+ * Reset password
+ *
+ * @return void
+ */
+ public function testResetPassword()
+ {
+ $user = $this->Users->newEntity();
+ $user->username = 'user-1';
+ $user->password = 'password';
+
+ $this->Shell->expects($this->once())
+ ->method('_updateUser')
+ ->will($this->returnValue($user));
+
+ $this->Shell->runCommand(['resetPassword', 'user-1', 'password']);
+ }
}
diff --git a/tests/TestCase/View/Helper/UserHelperTest.php b/tests/TestCase/View/Helper/UserHelperTest.php
index 249406620..7c8a36e36 100644
--- a/tests/TestCase/View/Helper/UserHelperTest.php
+++ b/tests/TestCase/View/Helper/UserHelperTest.php
@@ -187,6 +187,17 @@ public function testAddReCaptcha()
Configure::write('reCaptcha.key', $siteKey);
}
+ /**
+ * Test add ReCaptcha field
+ *
+ * @return void
+ */
+ public function testAddReCaptchaEmpty()
+ {
+ Configure::write('Users.Registration.reCaptcha', false);
+ $result = $this->User->addReCaptcha();
+ $this->assertFalse($result);
+ }
/**
* Test add ReCaptcha field
@@ -200,4 +211,18 @@ public function testAddReCaptchaScript()
->with('script', $this->stringContains('https://www.google.com/recaptcha/api.js'));
$this->User->addReCaptchaScript();
}
+
+ /**
+ * Test social login link
+ *
+ * @return void
+ */
+ public function testSocialLoginLink()
+ {
+ $result = $this->User->socialLogin('facebook');
+ $this->assertEquals('Sign in with Facebook', $result);
+
+ $result = $this->User->socialLogin('twitter', ['label' => 'Register with']);
+ $this->assertEquals('', $result);
+ }
}
From 93d4082822d6f64f120d05d2b7af9c957d7688ee Mon Sep 17 00:00:00 2001
From: Andy Carter
Date: Thu, 28 Jan 2016 19:19:22 +0000
Subject: [PATCH 0261/1397] Route prefix should be set to false by default
Fixes #28.
---
config/users.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/config/users.php b/config/users.php
index d332eade8..2921d5c1c 100644
--- a/config/users.php
+++ b/config/users.php
@@ -86,6 +86,7 @@
'plugin' => 'CakeDC/Users',
'controller' => 'Users',
'action' => 'login',
+ 'prefix' => false
],
'authenticate' => [
'all' => [
@@ -100,7 +101,7 @@
],
],
'OAuth' => [
- 'path' => ['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'socialLogin'],
+ 'path' => ['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'socialLogin', 'prefix' => false],
'providers' => [
'facebook' => [
'className' => 'League\OAuth2\Client\Provider\Facebook',
From 4d26db4ce4c4b340a444119637dd1715f3d94b78 Mon Sep 17 00:00:00 2001
From: Chris Mielke
Date: Fri, 29 Jan 2016 10:14:46 -0800
Subject: [PATCH 0262/1397] Add setup instructions for UserHelper
---
Docs/Documentation/UserHelper.md | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/Docs/Documentation/UserHelper.md b/Docs/Documentation/UserHelper.md
index 9abfce96d..062b8111e 100644
--- a/Docs/Documentation/UserHelper.md
+++ b/Docs/Documentation/UserHelper.md
@@ -6,7 +6,17 @@ The User Helper has some methods that may be needed if you want to improve your
Setup
---------------
-The User Helper just need some Configure variables to function properly.
+Enable the Helper in `src/view/AppView.php`:
+```php
+class AppView extends View
+{
+ public function initialize()
+ {
+ parent::initialize();
+ $this->loadHelper('CakeDC/Users.User');
+ }
+}
+```
Social Login
-----------------
@@ -62,4 +72,4 @@ $this->User->addReCaptchaScript();
$this->User->addReCaptcha();
```
-Note that the script is added automatically if the feature is enabled in config.
\ No newline at end of file
+Note that the script is added automatically if the feature is enabled in config.
From c9c39f7e4b9c00db23e35790da0089aca8766d4e Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Sun, 31 Jan 2016 15:38:19 +0000
Subject: [PATCH 0263/1397] add required lib for testing
---
composer.json | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/composer.json b/composer.json
index 4fe069456..70781da3f 100644
--- a/composer.json
+++ b/composer.json
@@ -7,10 +7,10 @@
"cakephp/cakephp": "3.1.*"
},
"require-dev": {
- "phpunit/phpunit": "*"
+ "phpunit/phpunit": "*",
+ "muffin/oauth2": "dev-master"
},
"suggest": {
- "muffin/oauth2": "Provide Social Authentication",
"league/oauth2-facebook": "Provide Social Authentication with Facebook",
"league/oauth2-instagram": "Provide Social Authentication with Instagram",
"google/recaptcha": "Provide reCAPTCHA validation for registration form"
From 1d4a28164cb8408e130f8b310f510ef8368e345e Mon Sep 17 00:00:00 2001
From: jorge gonzalez
Date: Sun, 31 Jan 2016 15:38:19 +0000
Subject: [PATCH 0264/1397] add required lib for testing
---
composer.json | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 4fe069456..c36114d7c 100644
--- a/composer.json
+++ b/composer.json
@@ -7,7 +7,8 @@
"cakephp/cakephp": "3.1.*"
},
"require-dev": {
- "phpunit/phpunit": "*"
+ "phpunit/phpunit": "*",
+ "muffin/oauth2": "dev-master"
},
"suggest": {
"muffin/oauth2": "Provide Social Authentication",
From 4cc3ed4afc37bbf96b391a2f20bc25691aeb8bb7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Mon, 1 Feb 2016 10:51:53 +0000
Subject: [PATCH 0265/1397] fix return value in write context
---
src/Model/Behavior/SocialBehavior.php | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/Model/Behavior/SocialBehavior.php b/src/Model/Behavior/SocialBehavior.php
index a6d187e87..63533f1ec 100644
--- a/src/Model/Behavior/SocialBehavior.php
+++ b/src/Model/Behavior/SocialBehavior.php
@@ -137,6 +137,7 @@ protected function _populateUser($data, $existingUser, $useEmail, $validateEmail
}
$accountData['data'] = serialize(Hash::get($data, 'raw'));
$accountData['active'] = true;
+ $dataValidated = Hash::get($data, 'validated');
if (empty($existingUser)) {
@@ -154,8 +155,9 @@ protected function _populateUser($data, $existingUser, $useEmail, $validateEmail
$userData['username'] = Hash::get($data, 'username');
$username = Hash::get($userData, 'username');
if (empty($username)) {
- if (!empty(Hash::get($data, 'email'))) {
- $email = explode('@', Hash::get($data, 'email'));
+ $dataEmail = Hash::get($data, 'email');
+ if (!empty($dataEmail)) {
+ $email = explode('@', $dataEmail);
$userData['username'] = Hash::get($email, 0);
} else {
$firstName = Hash::get($userData, 'first_name');
@@ -167,14 +169,14 @@ protected function _populateUser($data, $existingUser, $useEmail, $validateEmail
$userData['username'] = $this->generateUniqueUsername(Hash::get($userData, 'username'));
if ($useEmail) {
$userData['email'] = Hash::get($data, 'email');
- if (empty(Hash::get($data, 'validated'))) {
+ if (empty($dataValidated)) {
$accountData['active'] = false;
}
}
$userData['password'] = $this->randomString();
$userData['avatar'] = Hash::get($data, 'avatar');
- $userData['validated'] = !empty(Hash::get($data, 'validated'));
+ $userData['validated'] = !empty($dataValidated);
$userData['tos_date'] = date("Y-m-d H:i:s");
$userData['gender'] = Hash::get($data, 'gender');
//$userData['timezone'] = Hash::get($data, 'timezone');
@@ -182,7 +184,7 @@ protected function _populateUser($data, $existingUser, $useEmail, $validateEmail
$user = $this->_table->newEntity($userData, ['associated' => ['SocialAccounts']]);
$user = $this->_updateActive($user, false, $tokenExpiration);
} else {
- if ($useEmail && empty(Hash::get($data, 'validated'))) {
+ if ($useEmail && empty($dataValidated)) {
$accountData['active'] = false;
}
$user = $this->_table->patchEntity($existingUser, [
From aea0c1b9483afab0571e9372369f61f7a088f197 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Mon, 1 Feb 2016 17:28:52 +0000
Subject: [PATCH 0266/1397] fix empty return values in 5.4
---
src/Auth/SocialAuthenticate.php | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/Auth/SocialAuthenticate.php b/src/Auth/SocialAuthenticate.php
index 29c43ba85..eb526764f 100755
--- a/src/Auth/SocialAuthenticate.php
+++ b/src/Auth/SocialAuthenticate.php
@@ -94,9 +94,10 @@ protected function _touch(array $data)
public function getUser(Request $request)
{
$data = $request->session()->read(Configure::read('Users.Key.Session.social'));
- if (!empty($data) && (!empty($data['email'] || !empty($request->data('email'))))) {
- if (!empty($request->data('email'))) {
- $data['email'] = $request->data('email');
+ $requestDataEmail = $request->data('email');
+ if (!empty($data) && (!empty($data['email']) || !empty($requestDataEmail))) {
+ if (!empty($requestDataEmail)) {
+ $data['email'] = $requestDataEmail;
}
$user = $data;
$request->session()->delete(Configure::read('Users.Key.Session.social'));
From 185b7524b0027b2161038873a960c00502b44da8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Mon, 1 Feb 2016 17:45:04 +0000
Subject: [PATCH 0267/1397] fix empty return values in 5.4
---
src/Auth/Social/Mapper/AbstractMapper.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/Auth/Social/Mapper/AbstractMapper.php b/src/Auth/Social/Mapper/AbstractMapper.php
index 590a9fc84..136179b53 100644
--- a/src/Auth/Social/Mapper/AbstractMapper.php
+++ b/src/Auth/Social/Mapper/AbstractMapper.php
@@ -71,7 +71,8 @@ public function __invoke()
*/
protected function _validated()
{
- return !empty(Hash::get($this->_rawData, $this->_mapFields['email']));
+ $email = Hash::get($this->_rawData, $this->_mapFields['email']);
+ return !empty($email);
}
/**
From 7adf8a035cf9569deda6bbe177805e248f821953 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Mon, 1 Feb 2016 17:52:46 +0000
Subject: [PATCH 0268/1397] fix travis php version for coveralls
---
.travis.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index b9669e624..cc347134b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -20,10 +20,10 @@ matrix:
fast_finish: true
include:
- - php: 5.4
+ - php: 5.5
env: PHPCS=1 DEFAULT=0
- - php: 5.4
+ - php: 5.5
env: COVERALLS=1 DEFAULT=0 DB=mysql db_dsn='mysql://travis@0.0.0.0/cakephp_test'
before_script:
From 336556cced58784c53a995fef1f4fd89f5ae50d2 Mon Sep 17 00:00:00 2001
From: Yelitza Parra
Date: Tue, 2 Feb 2016 09:34:46 -0500
Subject: [PATCH 0269/1397] Fixing typos
---
src/Auth/SimpleRbacAuthorize.php | 2 +-
src/Locale/Users.pot | 2 +-
src/Model/Behavior/Behavior.php | 2 +-
src/Template/Email/html/validation.ctp | 2 +-
src/View/Helper/UserHelper.php | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/Auth/SimpleRbacAuthorize.php b/src/Auth/SimpleRbacAuthorize.php
index 5847e5e15..03bcaf3fc 100644
--- a/src/Auth/SimpleRbacAuthorize.php
+++ b/src/Auth/SimpleRbacAuthorize.php
@@ -168,7 +168,7 @@ public function authorize($user, Request $request)
* @param array $user current user array
* @param string $role effective role for the current user
* @param Request $request request
- * @return bool true if there is a match in permissisons
+ * @return bool true if there is a match in permissions
*/
protected function _checkRules(array $user, $role, Request $request)
{
diff --git a/src/Locale/Users.pot b/src/Locale/Users.pot
index 79f386803..551c6cda2 100644
--- a/src/Locale/Users.pot
+++ b/src/Locale/Users.pot
@@ -270,7 +270,7 @@ msgstr ""
#: Template/Email/html/reset_password.ctp:27
#: Template/Email/html/social_account_validation.ctp:32
#: Template/Email/html/validation.ctp:27
-msgid "If the link is not correcly displayed, please copy the following address in your web browser {0}"
+msgid "If the link is not correctly displayed, please copy the following address in your web browser {0}"
msgstr ""
#: Template/Email/html/reset_password.ctp:30
diff --git a/src/Model/Behavior/Behavior.php b/src/Model/Behavior/Behavior.php
index d0307d980..32e6d2aba 100644
--- a/src/Model/Behavior/Behavior.php
+++ b/src/Model/Behavior/Behavior.php
@@ -23,7 +23,7 @@ class Behavior extends BaseBehavior
{
/**
- * Send the templated email to the user
+ * Send the template email to the user
*
* @param EntityInterface $user User entity
* @param string $subject Subject, note the first_name of the user will be prepended if exists
diff --git a/src/Template/Email/html/validation.ctp b/src/Template/Email/html/validation.ctp
index dbdc2fe4f..df1dc3fe2 100644
--- a/src/Template/Email/html/validation.ctp
+++ b/src/Template/Email/html/validation.ctp
@@ -24,7 +24,7 @@ $activationUrl = [
= $this->Html->link(__d('Users', 'Activate your account here'), $activationUrl) ?>
- = __d('Users', "If the link is not correcly displayed, please copy the following address in your web browser {0}", $this->Url->build($activationUrl)) ?>
+ = __d('Users', "If the link is not correctly displayed, please copy the following address in your web browser {0}", $this->Url->build($activationUrl)) ?>
= __d('Users', 'Thank you') ?>,
diff --git a/src/View/Helper/UserHelper.php b/src/View/Helper/UserHelper.php
index 1dd5a4e7e..843cf2531 100644
--- a/src/View/Helper/UserHelper.php
+++ b/src/View/Helper/UserHelper.php
@@ -34,7 +34,7 @@ class UserHelper extends Helper
protected $_defaultConfig = [];
/**
- * beforeLayou callback loads reCaptcha if enabled
+ * beforeLayout callback loads reCaptcha if enabled
*
* @param Event $event event
* @return void
From 8e7a7bcf33bcaeb47ea43c0d91596c0b5825f5b9 Mon Sep 17 00:00:00 2001
From: Yelitza Parra
Date: Tue, 2 Feb 2016 09:39:05 -0500
Subject: [PATCH 0270/1397] Adding necessary @throws tags to comment blocks
---
src/Controller/Traits/LoginTrait.php | 3 +++
src/Controller/Traits/RegisterTrait.php | 1 +
src/Model/Behavior/PasswordBehavior.php | 1 +
src/Model/Behavior/SocialBehavior.php | 3 +++
4 files changed, 8 insertions(+)
diff --git a/src/Controller/Traits/LoginTrait.php b/src/Controller/Traits/LoginTrait.php
index caf05066d..9fc519a90 100644
--- a/src/Controller/Traits/LoginTrait.php
+++ b/src/Controller/Traits/LoginTrait.php
@@ -106,6 +106,9 @@ public function failedSocialLogin($exception, $data, $flash = false)
}
/**
+ * Social login
+ *
+ * @throws NotFoundException
* @return array
*/
public function socialLogin()
diff --git a/src/Controller/Traits/RegisterTrait.php b/src/Controller/Traits/RegisterTrait.php
index b572b6811..5c3b0293b 100644
--- a/src/Controller/Traits/RegisterTrait.php
+++ b/src/Controller/Traits/RegisterTrait.php
@@ -30,6 +30,7 @@ trait RegisterTrait
/**
* Register a new user
*
+ * @throws NotFoundException
* @return type
*/
public function register()
diff --git a/src/Model/Behavior/PasswordBehavior.php b/src/Model/Behavior/PasswordBehavior.php
index fc87c150d..03c0bc6ec 100644
--- a/src/Model/Behavior/PasswordBehavior.php
+++ b/src/Model/Behavior/PasswordBehavior.php
@@ -105,6 +105,7 @@ public function sendResetPasswordEmail(EntityInterface $user, Email $email = nul
* Change password method
*
* @param EntityInterface $user user data.
+ * @throws WrongPasswordException
* @return mixed
*/
public function changePassword(EntityInterface $user)
diff --git a/src/Model/Behavior/SocialBehavior.php b/src/Model/Behavior/SocialBehavior.php
index 63533f1ec..9b8d5d33c 100644
--- a/src/Model/Behavior/SocialBehavior.php
+++ b/src/Model/Behavior/SocialBehavior.php
@@ -35,6 +35,9 @@ class SocialBehavior extends Behavior
*
* @param array $data Array social login.
* @param array $options Array option data.
+ * @throws InvalidArgumentException
+ * @throws UserNotActiveException
+ * @throws AccountNotActiveException
* @return bool|EntityInterface|mixed
*/
public function socialLogin(array $data, array $options)
From 94f808f2f5489b7d29891f5fb99636d9779d3340 Mon Sep 17 00:00:00 2001
From: Yelitza Parra
Date: Tue, 2 Feb 2016 09:44:24 -0500
Subject: [PATCH 0271/1397] Fixing comment to make it match with the method
signature
---
src/Model/Behavior/Behavior.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Model/Behavior/Behavior.php b/src/Model/Behavior/Behavior.php
index 32e6d2aba..95764a8d9 100644
--- a/src/Model/Behavior/Behavior.php
+++ b/src/Model/Behavior/Behavior.php
@@ -87,7 +87,7 @@ protected function _updateActive(EntityInterface $user, $validateEmail, $tokenEx
/**
* Remove user token for validation
*
- * @param User $user user object.
+ * @param EntityInterface $user user object.
* @return EntityInterface
*/
protected function _removeValidationToken(EntityInterface $user)
From 1f79fc633d5038ac25360d758e1e5571732b4e90 Mon Sep 17 00:00:00 2001
From: Yelitza Parra
Date: Tue, 2 Feb 2016 10:03:19 -0500
Subject: [PATCH 0272/1397] Fixed param type in comment block
---
src/Model/Behavior/Behavior.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Model/Behavior/Behavior.php b/src/Model/Behavior/Behavior.php
index 95764a8d9..26226c29c 100644
--- a/src/Model/Behavior/Behavior.php
+++ b/src/Model/Behavior/Behavior.php
@@ -66,7 +66,7 @@ protected function _getEmailInstance(Email $email = null)
* DRY for update active and token based on validateEmail flag
*
* @param EntityInterface $user User to be updated.
- * @param type $validateEmail email user to validate.
+ * @param bool $validateEmail email user to validate.
* @param type $tokenExpiration token to be updated.
* @return EntityInterface
*/
From 10c9fa84421c01cec9ac87144bebe8672db95cb2 Mon Sep 17 00:00:00 2001
From: Yelitza Parra
Date: Tue, 2 Feb 2016 10:30:41 -0500
Subject: [PATCH 0273/1397] Removed unused references
---
src/Auth/SocialAuthenticate.php | 2 --
src/Controller/Component/RememberMeComponent.php | 1 -
src/Controller/Traits/LoginTrait.php | 1 -
src/Controller/Traits/RegisterTrait.php | 1 -
src/Controller/Traits/SimpleCrudTrait.php | 1 -
src/Controller/Traits/UserValidationTrait.php | 1 -
src/Model/Behavior/RegisterBehavior.php | 1 -
src/Model/Behavior/SocialAccountBehavior.php | 4 ----
src/Model/Entity/User.php | 1 -
src/Model/Table/SocialAccountsTable.php | 8 --------
src/Model/Table/UsersTable.php | 4 ----
11 files changed, 25 deletions(-)
diff --git a/src/Auth/SocialAuthenticate.php b/src/Auth/SocialAuthenticate.php
index eb526764f..b618b5e07 100755
--- a/src/Auth/SocialAuthenticate.php
+++ b/src/Auth/SocialAuthenticate.php
@@ -13,8 +13,6 @@
use Cake\Controller\ComponentRegistry;
use Cake\Core\Configure;
-use Cake\Error\Debugger;
-use Cake\Log\Log;
use Cake\Network\Request;
use Cake\ORM\TableRegistry;
use CakeDC\Users\Auth\Social\Util\SocialUtils;
diff --git a/src/Controller/Component/RememberMeComponent.php b/src/Controller/Component/RememberMeComponent.php
index 1293b1ede..488fa272f 100644
--- a/src/Controller/Component/RememberMeComponent.php
+++ b/src/Controller/Component/RememberMeComponent.php
@@ -14,7 +14,6 @@
use Cake\Controller\Component;
use Cake\Core\Configure;
use Cake\Event\Event;
-use Cake\ORM\TableRegistry;
use Cake\Utility\Security;
use InvalidArgumentException;
diff --git a/src/Controller/Traits/LoginTrait.php b/src/Controller/Traits/LoginTrait.php
index 9fc519a90..db5d32e37 100644
--- a/src/Controller/Traits/LoginTrait.php
+++ b/src/Controller/Traits/LoginTrait.php
@@ -17,7 +17,6 @@
use CakeDC\Users\Exception\AccountNotActiveException;
use CakeDC\Users\Exception\MissingEmailException;
use Cake\Core\Configure;
-use Cake\Utility\Hash;
use CakeDC\Users\Exception\UserNotActiveException;
use League\OAuth1\Client\Server\Twitter;
diff --git a/src/Controller/Traits/RegisterTrait.php b/src/Controller/Traits/RegisterTrait.php
index 5c3b0293b..a6a832870 100644
--- a/src/Controller/Traits/RegisterTrait.php
+++ b/src/Controller/Traits/RegisterTrait.php
@@ -16,7 +16,6 @@
use Cake\Datasource\EntityInterface;
use Cake\Network\Exception\NotFoundException;
use Cake\Network\Response;
-use InvalidArgumentException;
/**
* Covers registration features and email token validation
diff --git a/src/Controller/Traits/SimpleCrudTrait.php b/src/Controller/Traits/SimpleCrudTrait.php
index 34b0b7634..63fd75b72 100644
--- a/src/Controller/Traits/SimpleCrudTrait.php
+++ b/src/Controller/Traits/SimpleCrudTrait.php
@@ -13,7 +13,6 @@
use Cake\Network\Exception\NotFoundException;
use Cake\Network\Response;
-use Cake\ORM\TableRegistry;
use Cake\Utility\Inflector;
/**
diff --git a/src/Controller/Traits/UserValidationTrait.php b/src/Controller/Traits/UserValidationTrait.php
index 5a24003e8..74836e61a 100644
--- a/src/Controller/Traits/UserValidationTrait.php
+++ b/src/Controller/Traits/UserValidationTrait.php
@@ -17,7 +17,6 @@
use Cake\Core\Configure;
use Cake\Network\Response;
use Exception;
-use InvalidArgumentException;
/**
* Covers the user validation
diff --git a/src/Model/Behavior/RegisterBehavior.php b/src/Model/Behavior/RegisterBehavior.php
index 3d065f7fe..4f8f33d56 100644
--- a/src/Model/Behavior/RegisterBehavior.php
+++ b/src/Model/Behavior/RegisterBehavior.php
@@ -14,7 +14,6 @@
use CakeDC\Users\Exception\TokenExpiredException;
use CakeDC\Users\Exception\UserAlreadyActiveException;
use CakeDC\Users\Exception\UserNotFoundException;
-use CakeDC\Users\Model\Behavior\Behavior;
use CakeDC\Users\Model\Entity\User;
use Cake\Core\Configure;
use Cake\Datasource\EntityInterface;
diff --git a/src/Model/Behavior/SocialAccountBehavior.php b/src/Model/Behavior/SocialAccountBehavior.php
index 8b37502b2..0f7a7d18a 100644
--- a/src/Model/Behavior/SocialAccountBehavior.php
+++ b/src/Model/Behavior/SocialAccountBehavior.php
@@ -13,9 +13,6 @@
use ArrayObject;
use CakeDC\Users\Exception\AccountAlreadyActiveException;
-use CakeDC\Users\Exception\AccountNotActiveException;
-use CakeDC\Users\Exception\MissingEmailException;
-use CakeDC\Users\Model\Behavior\Behavior;
use CakeDC\Users\Model\Entity\User;
use Cake\Core\Configure;
use Cake\Datasource\EntityInterface;
@@ -23,7 +20,6 @@
use Cake\Event\Event;
use Cake\Mailer\Email;
use Cake\ORM\Entity;
-use InvalidArgumentException;
/**
* Covers social account features
diff --git a/src/Model/Entity/User.php b/src/Model/Entity/User.php
index 14a9b6426..5e3a4c15d 100644
--- a/src/Model/Entity/User.php
+++ b/src/Model/Entity/User.php
@@ -11,7 +11,6 @@
namespace CakeDC\Users\Model\Entity;
-use Cake\Auth\DefaultPasswordHasher;
use Cake\Core\Configure;
use Cake\ORM\Entity;
use Cake\Utility\Text;
diff --git a/src/Model/Table/SocialAccountsTable.php b/src/Model/Table/SocialAccountsTable.php
index dc06716d2..f753d0e81 100644
--- a/src/Model/Table/SocialAccountsTable.php
+++ b/src/Model/Table/SocialAccountsTable.php
@@ -11,15 +11,7 @@
namespace CakeDC\Users\Model\Table;
-use ArrayObject;
-use CakeDC\Users\Exception\AccountAlreadyActiveException;
-use CakeDC\Users\Model\Entity\User;
use Cake\Core\Configure;
-use Cake\Datasource\EntityInterface;
-use Cake\Datasource\Exception\RecordNotFoundException;
-use Cake\Event\Event;
-use Cake\Mailer\Email;
-use Cake\ORM\Entity;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
diff --git a/src/Model/Table/UsersTable.php b/src/Model/Table/UsersTable.php
index 984628e5d..1314f173a 100644
--- a/src/Model/Table/UsersTable.php
+++ b/src/Model/Table/UsersTable.php
@@ -11,10 +11,6 @@
namespace CakeDC\Users\Model\Table;
-use CakeDC\Users\Exception\WrongPasswordException;
-use CakeDC\Users\Model\Entity\User;
-use Cake\Datasource\EntityInterface;
-use Cake\Mailer\Email;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Utility\Hash;
From 021a2e83053d2d4ad0afb2da9922b06bdd80b3e7 Mon Sep 17 00:00:00 2001
From: Yelitza Parra
Date: Tue, 2 Feb 2016 10:33:45 -0500
Subject: [PATCH 0274/1397] Removed commented code
---
tests/TestCase/Controller/Traits/LoginTraitTest.php | 8 --------
tests/TestCase/Model/Behavior/SocialBehaviorTest.php | 2 +-
2 files changed, 1 insertion(+), 9 deletions(-)
diff --git a/tests/TestCase/Controller/Traits/LoginTraitTest.php b/tests/TestCase/Controller/Traits/LoginTraitTest.php
index a8c1e12e3..e2ca3f370 100644
--- a/tests/TestCase/Controller/Traits/LoginTraitTest.php
+++ b/tests/TestCase/Controller/Traits/LoginTraitTest.php
@@ -141,18 +141,10 @@ public function testAfterIdentifyEmptyUserSocialLogin()
$this->Trait->request = $this->getMockBuilder('Cake\Network\Request')
->setMethods(['is'])
->getMock();
- /*$this->Trait->request->expects($this->once())
- ->method('is')
- ->with('post')
- ->will($this->returnValue(true));*/
$this->Trait->Auth = $this->getMockBuilder('Cake\Controller\Component\AuthComponent')
->setMethods(['user', 'identify', 'setUser', 'redirectUrl'])
->disableOriginalConstructor()
->getMock();
- $user = [];
- /* $this->Trait->Auth->expects($this->once())
- ->method('identify')
- ->will($this->returnValue($user));*/
$this->Trait->expects($this->once())
->method('redirect')
diff --git a/tests/TestCase/Model/Behavior/SocialBehaviorTest.php b/tests/TestCase/Model/Behavior/SocialBehaviorTest.php
index 83cbb908a..600b49465 100644
--- a/tests/TestCase/Model/Behavior/SocialBehaviorTest.php
+++ b/tests/TestCase/Model/Behavior/SocialBehaviorTest.php
@@ -298,7 +298,7 @@ public function providerSocialLoginExistingAccountNotActiveUser()
*/
public function testSocialLoginNoEmail($data, $options)
{
- $result = $this->Behavior->socialLogin($data, $options);
+ $this->Behavior->socialLogin($data, $options);
}
From 8a56fab75a363374f6b6af5f78184be0916ed551 Mon Sep 17 00:00:00 2001
From: Yelitza Parra
Date: Tue, 2 Feb 2016 10:54:27 -0500
Subject: [PATCH 0275/1397] phpcs fixes
---
src/Auth/Social/Mapper/AbstractMapper.php | 18 ++++++++++++++----
src/Auth/Social/Mapper/Facebook.php | 13 +++++++++++++
src/Auth/Social/Mapper/Google.php | 15 +++++++++++----
src/Auth/Social/Mapper/Instagram.php | 15 +++++++++++----
src/Auth/Social/Mapper/LinkedIn.php | 11 +++++++----
src/Auth/Social/Mapper/Twitter.php | 16 +++++++++++-----
src/Auth/Social/Util/SocialUtils.php | 16 ++++++++++++----
src/Template/Users/change_password.ctp | 6 +++++-
8 files changed, 84 insertions(+), 26 deletions(-)
diff --git a/src/Auth/Social/Mapper/AbstractMapper.php b/src/Auth/Social/Mapper/AbstractMapper.php
index 136179b53..7c307e354 100644
--- a/src/Auth/Social/Mapper/AbstractMapper.php
+++ b/src/Auth/Social/Mapper/AbstractMapper.php
@@ -1,15 +1,22 @@
- = $this->Form->input('current_password', ['type' => 'password', 'required' => true, 'label' => __d('Users', 'Current password')]); ?>
+ = $this->Form->input('current_password', [
+ 'type' => 'password',
+ 'required' => true,
+ 'label' => __d('Users', 'Current password')]);
+ ?>
= $this->Form->input('password'); ?>
= $this->Form->input('password_confirm', ['type' => 'password', 'required' => true]); ?>
From 18166ffbfc5bcd60ac47975fcc374a320a6e0577 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20M=2E=20Gonz=C3=A1lez=20Mart=C3=ADn?=
Date: Fri, 5 Feb 2016 14:24:11 +0000
Subject: [PATCH 0276/1397] update composer requirements
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 4fe069456..349fb7a37 100644
--- a/composer.json
+++ b/composer.json
@@ -4,7 +4,7 @@
"type": "cakephp-plugin",
"require": {
"php": ">=5.4.16",
- "cakephp/cakephp": "3.1.*"
+ "cakephp/cakephp": "~3.1"
},
"require-dev": {
"phpunit/phpunit": "*"
From cc139a24463d129191b9f4b6a366f07db2cd3985 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Sat, 6 Feb 2016 16:36:59 +0000
Subject: [PATCH 0277/1397] refs #fix-tests fix required oauth2 lib
---
composer.json | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/composer.json b/composer.json
index e1e77e741..5cbd591c5 100644
--- a/composer.json
+++ b/composer.json
@@ -4,11 +4,11 @@
"type": "cakephp-plugin",
"require": {
"php": ">=5.4.16",
- "cakephp/cakephp": "~3.1"
+ "cakephp/cakephp": "~3.1",
+ "muffin/oauth2": "dev-master"
},
"require-dev": {
- "phpunit/phpunit": "*",
- "muffin/oauth2": "dev-master"
+ "phpunit/phpunit": "*"
},
"suggest": {
"league/oauth2-facebook": "Provide Social Authentication with Facebook",
From c274f561eeda03389fee559005cab69ae924fe68 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Sat, 6 Feb 2016 16:53:05 +0000
Subject: [PATCH 0278/1397] disable social authentication by default to get rid
of exceptions if providers not found when loading SocialAuthenticate
---
config/users.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/users.php b/config/users.php
index 2921d5c1c..a225a0293 100644
--- a/config/users.php
+++ b/config/users.php
@@ -39,7 +39,7 @@
],
'Social' => [
//enable social login
- 'login' => true,
+ 'login' => false,
],
'Profile' => [
//Allow view other users profiles
From 78b556a824bd136db4eb1b04708a2f1453e6f9a9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Sat, 6 Feb 2016 17:02:58 +0000
Subject: [PATCH 0279/1397] refs #fix-tests fix test default social login
disabled now
---
tests/TestCase/Controller/Component/UsersAuthComponentTest.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/tests/TestCase/Controller/Component/UsersAuthComponentTest.php b/tests/TestCase/Controller/Component/UsersAuthComponentTest.php
index 2c45e2f9c..3138bb384 100644
--- a/tests/TestCase/Controller/Component/UsersAuthComponentTest.php
+++ b/tests/TestCase/Controller/Component/UsersAuthComponentTest.php
@@ -106,8 +106,6 @@ public function testInitializeNoRequiredRememberMe()
->getMock();
$this->Controller->UsersAuth->expects($this->once())
->method('_initAuth');
- $this->Controller->UsersAuth->expects($this->once())
- ->method('_loadSocialLogin');
$this->Controller->UsersAuth->expects($this->never())
->method('_loadRememberMe');
$this->Controller->UsersAuth->initialize([]);
From 035a73763d8464e3fe01e4cb33423e19c29e9ef3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Sat, 6 Feb 2016 17:34:24 +0000
Subject: [PATCH 0280/1397] add missing dependencies, fix phpcs
---
composer.json | 6 ++--
src/Auth/Social/Mapper/AbstractMapper.php | 4 +--
src/Auth/Social/Mapper/LinkedIn.php | 2 +-
src/Auth/Social/Mapper/Twitter.php | 2 +-
src/Auth/Social/Util/SocialUtils.php | 5 +--
src/Auth/SocialAuthenticate.php | 17 ++++++----
src/Controller/Traits/LoginTrait.php | 33 +++++++++++--------
src/Controller/Traits/ProfileTrait.php | 3 +-
src/Model/Behavior/SocialBehavior.php | 7 ++--
src/Shell/UsersShell.php | 3 +-
src/View/Helper/UserHelper.php | 10 +++---
.../TestCase/Auth/SocialAuthenticateTest.php | 25 +++++++-------
.../Model/Behavior/SocialBehaviorTest.php | 21 ++++--------
tests/TestCase/Model/Table/UsersTableTest.php | 9 +++--
14 files changed, 76 insertions(+), 71 deletions(-)
diff --git a/composer.json b/composer.json
index 5cbd591c5..dfc76803d 100644
--- a/composer.json
+++ b/composer.json
@@ -5,10 +5,12 @@
"require": {
"php": ">=5.4.16",
"cakephp/cakephp": "~3.1",
- "muffin/oauth2": "dev-master"
+ "muffin/oauth2": "dev-master",
+ "league/oauth1-client": "@stable"
},
"require-dev": {
- "phpunit/phpunit": "*"
+ "phpunit/phpunit": "*",
+ "cakephp/cakephp-codesniffer": "^2.0"
},
"suggest": {
"league/oauth2-facebook": "Provide Social Authentication with Facebook",
diff --git a/src/Auth/Social/Mapper/AbstractMapper.php b/src/Auth/Social/Mapper/AbstractMapper.php
index 7c307e354..0a738b0d6 100644
--- a/src/Auth/Social/Mapper/AbstractMapper.php
+++ b/src/Auth/Social/Mapper/AbstractMapper.php
@@ -53,8 +53,8 @@ abstract class AbstractMapper
/**
* Constructor
*
- * @param $rawData
- * @param null $mapFields
+ * @param mixed $rawData raw data
+ * @param mixed $mapFields map fields
*/
public function __construct($rawData, $mapFields = null)
{
diff --git a/src/Auth/Social/Mapper/LinkedIn.php b/src/Auth/Social/Mapper/LinkedIn.php
index fa01829a4..6edd447eb 100644
--- a/src/Auth/Social/Mapper/LinkedIn.php
+++ b/src/Auth/Social/Mapper/LinkedIn.php
@@ -25,4 +25,4 @@ class LinkedIn extends AbstractMapper
'bio' => 'headline',
'link' => 'publicProfileUrl'
];
-}
\ No newline at end of file
+}
diff --git a/src/Auth/Social/Mapper/Twitter.php b/src/Auth/Social/Mapper/Twitter.php
index a078f8a95..cf2bfe37b 100644
--- a/src/Auth/Social/Mapper/Twitter.php
+++ b/src/Auth/Social/Mapper/Twitter.php
@@ -48,4 +48,4 @@ protected function _link()
{
return self::TWITTER_BASE_URL . Hash::get($this->_rawData, $this->_mapFields['username']);
}
-}
\ No newline at end of file
+}
diff --git a/src/Auth/Social/Util/SocialUtils.php b/src/Auth/Social/Util/SocialUtils.php
index d67b1ee47..9fedd1779 100644
--- a/src/Auth/Social/Util/SocialUtils.php
+++ b/src/Auth/Social/Util/SocialUtils.php
@@ -22,7 +22,8 @@ class SocialUtils
{
/**
* Get provider from classname
- * @param AbstractProvider $provider
+ *
+ * @param AbstractProvider $provider provider
* @return string
*/
public static function getProvider(AbstractProvider $provider)
@@ -30,4 +31,4 @@ public static function getProvider(AbstractProvider $provider)
$reflect = new ReflectionClass($provider);
return $reflect->getShortName();
}
-}
\ No newline at end of file
+}
diff --git a/src/Auth/SocialAuthenticate.php b/src/Auth/SocialAuthenticate.php
index b618b5e07..4ee9e07c2 100755
--- a/src/Auth/SocialAuthenticate.php
+++ b/src/Auth/SocialAuthenticate.php
@@ -11,10 +11,6 @@
namespace CakeDC\Users\Auth;
-use Cake\Controller\ComponentRegistry;
-use Cake\Core\Configure;
-use Cake\Network\Request;
-use Cake\ORM\TableRegistry;
use CakeDC\Users\Auth\Social\Util\SocialUtils;
use CakeDC\Users\Controller\Component\UsersAuthComponent;
use CakeDC\Users\Exception\AccountNotActiveException;
@@ -22,6 +18,10 @@
use CakeDC\Users\Exception\MissingProviderException;
use CakeDC\Users\Exception\UserNotActiveException;
use CakeDC\Users\Model\Table\SocialAccountsTable;
+use Cake\Controller\ComponentRegistry;
+use Cake\Core\Configure;
+use Cake\Network\Request;
+use Cake\ORM\TableRegistry;
use Muffin\OAuth2\Auth\OAuthAuthenticate;
/**
@@ -47,7 +47,8 @@ public function __construct(ComponentRegistry $registry, array $config = [])
/**
* Find or create local user
- * @param array $data
+ *
+ * @param array $data data
* @return array|bool|mixed
* @throws MissingEmailException
*/
@@ -132,7 +133,7 @@ protected function _getProviderName($request = null)
$provider = false;
if (!is_null($this->_provider)) {
$provider = SocialUtils::getProvider($this->_provider);
- } else if (!empty($request)){
+ } elseif (!empty($request)) {
$provider = ucfirst($request->param('provider'));
}
return $provider;
@@ -158,6 +159,10 @@ protected function _mapUser($provider, $data)
return $user;
}
+ /**
+ * @param mixed $data data
+ * @return mixed
+ */
protected function _socialLogin($data)
{
$options = [
diff --git a/src/Controller/Traits/LoginTrait.php b/src/Controller/Traits/LoginTrait.php
index db5d32e37..152b78b7a 100644
--- a/src/Controller/Traits/LoginTrait.php
+++ b/src/Controller/Traits/LoginTrait.php
@@ -11,13 +11,13 @@
namespace CakeDC\Users\Controller\Traits;
-use Cake\Event\Event;
-use Cake\Network\Exception\NotFoundException;
use CakeDC\Users\Controller\Component\UsersAuthComponent;
use CakeDC\Users\Exception\AccountNotActiveException;
use CakeDC\Users\Exception\MissingEmailException;
-use Cake\Core\Configure;
use CakeDC\Users\Exception\UserNotActiveException;
+use Cake\Core\Configure;
+use Cake\Event\Event;
+use Cake\Network\Exception\NotFoundException;
use League\OAuth1\Client\Server\Twitter;
/**
@@ -28,7 +28,13 @@ trait LoginTrait
{
use CustomUsersTableTrait;
- public function twitterLogin() {
+ /**
+ * Do twitter login
+ *
+ * @return mixed|void
+ */
+ public function twitterLogin()
+ {
$this->autoRender = false;
$server = new Twitter([
@@ -65,25 +71,26 @@ public function twitterLogin() {
$this->request->session()->write('temporary_credentials', $temporaryCredentials);
$server->authorize($temporaryCredentials);
}
- return;
}
/**
- * @param $event
+ * @param Event $event event
+ * @return void
*/
- public function failedSocialLoginListener(Event $event) {
+ public function failedSocialLoginListener(Event $event)
+ {
$this->failedSocialLogin($event->data['exception'], $event->data['rawData'], true);
}
/**
- * @param $exception
- * @param $data
- * @param bool|false $flash
+ * @param mixed $exception exception
+ * @param mixed $data data
+ * @param bool|false $flash flash
* @return mixed
*/
public function failedSocialLogin($exception, $data, $flash = false)
{
$msg = __d('Users', 'Issues trying to log in with your social account');
- if (isset($exception) ) {
+ if (isset($exception)) {
if ($exception instanceof MissingEmailException) {
if ($flash) {
$this->Flash->success(__d('Users', 'Please enter your email'));
@@ -120,8 +127,8 @@ public function socialLogin()
}
$user = $this->Auth->user();
return $this->_afterIdentifyUser($user, true);
-
}
+
/**
* Login user
*
@@ -137,7 +144,7 @@ public function login()
return $this->redirect($event->result);
}
- $socialLogin = $this->_isSocialLogin();
+ $socialLogin = $this->_isSocialLogin();
if (!empty($socialLogin)) {
return $this->redirect(['action' => 'social-email']);
diff --git a/src/Controller/Traits/ProfileTrait.php b/src/Controller/Traits/ProfileTrait.php
index a9edbdd47..0d68ac6bc 100644
--- a/src/Controller/Traits/ProfileTrait.php
+++ b/src/Controller/Traits/ProfileTrait.php
@@ -11,6 +11,7 @@
namespace CakeDC\Users\Controller\Traits;
+use Cake\Controller\Component\AuthComponent;
use Cake\Core\Configure;
use Cake\Datasource\Exception\InvalidPrimaryKeyException;
use Cake\Datasource\Exception\RecordNotFoundException;
@@ -35,7 +36,7 @@ public function profile($id = null)
$id = $loggedUserId;
}
try {
- $appContain = (array)Configure::read('Auth.authenticate.' . \Cake\Controller\Component\AuthComponent::ALL . '.contain');
+ $appContain = (array)Configure::read('Auth.authenticate.' . AuthComponent::ALL . '.contain');
$socialContain = Configure::read('Users.Social.login') ? ['SocialAccounts']: [];
$user = $this->getUsersTable()->get($id, [
'contain' => array_merge((array)$appContain, (array)$socialContain)
diff --git a/src/Model/Behavior/SocialBehavior.php b/src/Model/Behavior/SocialBehavior.php
index 9b8d5d33c..f2f50ca05 100644
--- a/src/Model/Behavior/SocialBehavior.php
+++ b/src/Model/Behavior/SocialBehavior.php
@@ -11,12 +11,12 @@
namespace CakeDC\Users\Model\Behavior;
-use Cake\Event\EventDispatcherTrait;
use CakeDC\Users\Exception\AccountNotActiveException;
use CakeDC\Users\Exception\MissingEmailException;
use CakeDC\Users\Exception\UserNotActiveException;
use CakeDC\Users\Traits\RandomStringTrait;
use Cake\Datasource\EntityInterface;
+use Cake\Event\EventDispatcherTrait;
use Cake\Utility\Hash;
use DateTime;
use InvalidArgumentException;
@@ -27,8 +27,8 @@
*/
class SocialBehavior extends Behavior
{
- use RandomStringTrait;
use EventDispatcherTrait;
+ use RandomStringTrait;
/**
* Performs social login
@@ -143,7 +143,6 @@ protected function _populateUser($data, $existingUser, $useEmail, $validateEmail
$dataValidated = Hash::get($data, 'validated');
if (empty($existingUser)) {
-
$firstName = Hash::get($data, 'first_name');
$lastName = Hash::get($data, 'last_name');
if (!empty($firstName) && !empty($lastName)) {
@@ -180,7 +179,7 @@ protected function _populateUser($data, $existingUser, $useEmail, $validateEmail
$userData['password'] = $this->randomString();
$userData['avatar'] = Hash::get($data, 'avatar');
$userData['validated'] = !empty($dataValidated);
- $userData['tos_date'] = date("Y-m-d H:i:s");
+ $userData['tos_date'] = date("Y-m-d H:i:s");
$userData['gender'] = Hash::get($data, 'gender');
//$userData['timezone'] = Hash::get($data, 'timezone');
$userData['social_accounts'][] = $accountData;
diff --git a/src/Shell/UsersShell.php b/src/Shell/UsersShell.php
index 634b21462..dc544b6f3 100644
--- a/src/Shell/UsersShell.php
+++ b/src/Shell/UsersShell.php
@@ -16,6 +16,7 @@
use Cake\Console\Shell;
use Cake\Core\Configure;
use Cake\Utility\Hash;
+use Cake\Utility\Text;
/**
* Shell with utilities for the Users Plugin
@@ -336,7 +337,7 @@ public function deleteUser()
*/
protected function _generateRandomPassword()
{
- return str_replace('-', '', \Cake\Utility\Text::uuid());
+ return str_replace('-', '', Text::uuid());
}
/**
diff --git a/src/View/Helper/UserHelper.php b/src/View/Helper/UserHelper.php
index 843cf2531..50990edca 100644
--- a/src/View/Helper/UserHelper.php
+++ b/src/View/Helper/UserHelper.php
@@ -49,8 +49,8 @@ public function beforeLayout(Event $event)
/**
* Social login link
*
- * @param string $name
- * @param array $options
+ * @param string $name name
+ * @param array $options options
* @return string
*/
public function socialLogin($name, $options = [])
@@ -60,9 +60,9 @@ public function socialLogin($name, $options = [])
}
return $this->Html->link($this->Html->tag('i', '', [
'class' => __d('Users', 'fa fa-{0}', strtolower($name)),
- ]) . __d('Users', '{0} {1}', Hash::get($options, 'label') , Inflector::camelize($name)), "/auth/$name", [
- 'escape' => false, 'class' => __d('Users', 'btn btn-social btn-{0} ' . Hash::get($options, 'class') ? :'', strtolower($name))
- ]);
+ ]) . __d('Users', '{0} {1}', Hash::get($options, 'label'), Inflector::camelize($name)), "/auth/$name", [
+ 'escape' => false, 'class' => __d('Users', 'btn btn-social btn-{0} ' . Hash::get($options, 'class') ? :'', strtolower($name))
+ ]);
}
/**
diff --git a/tests/TestCase/Auth/SocialAuthenticateTest.php b/tests/TestCase/Auth/SocialAuthenticateTest.php
index cbdb3c9c2..c42ec7165 100644
--- a/tests/TestCase/Auth/SocialAuthenticateTest.php
+++ b/tests/TestCase/Auth/SocialAuthenticateTest.php
@@ -11,17 +11,15 @@
namespace CakeDC\Users\Test\TestCase\Auth;
-use Cake\ORM\TableRegistry;
+use CakeDC\Users\Exception\AccountNotActiveException;
+use CakeDC\Users\Exception\MissingEmailException;
+use CakeDC\Users\Exception\UserNotActiveException;
use Cake\Controller\ComponentRegistry;
-use Cake\Controller\Controller;
-use Cake\Event\EventManager;
use Cake\Event\Event;
use Cake\Network\Request;
use Cake\Network\Response;
+use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
-use CakeDC\Users\Exception\AccountNotActiveException;
-use CakeDC\Users\Exception\MissingEmailException;
-use CakeDC\Users\Exception\UserNotActiveException;
use ReflectionClass;
class SocialAuthenticateTest extends TestCase
@@ -95,7 +93,7 @@ public function testGetUserAuth($rawData, $mapper)
->method('_mapUser')
->will($this->returnValue($mapper));
- $user = $this->Table->get('00000000-0000-0000-0000-000000000002');
+ $user = $this->Table->get('00000000-0000-0000-0000-000000000002');
$this->SocialAuthenticate->expects($this->once())
->method('_socialLogin')
->will($this->returnValue($user));
@@ -128,7 +126,7 @@ public function providerGetUser()
'locale' => 'en_US',
'link' => 'link',
],
- 'mappedData' => [
+ 'mappedData' => [
'id' => 'reference-2-1',
'username' => null,
'full_name' => 'User S',
@@ -343,7 +341,7 @@ public function providerTwitter()
'locale' => 'en_US',
'link' => 'link',
],
- 'mappedData' => [
+ 'mappedData' => [
'id' => 'reference-2-1',
'username' => null,
'full_name' => 'User S',
@@ -428,7 +426,7 @@ public function providerMapper()
{
return [
[
- 'rawData' => [
+ 'rawData' => [
'id' => 'my-facebook-id',
'name' => 'My name.',
'first_name' => 'My first name',
@@ -438,7 +436,7 @@ public function providerMapper()
'locale' => 'en_US',
'link' => 'https://www.facebook.com/app_scoped_user_id/my-facebook-id/',
],
- 'mappedData' => [
+ 'mappedData' => [
'id' => 'my-facebook-id',
'username' => null,
'full_name' => 'My name.',
@@ -454,11 +452,11 @@ public function providerMapper()
'credentials' => [
'token' => 'token',
'secret' => null,
- 'expires' => (int) 1458510952
+ 'expires' => (int)1458510952
],
'provider' => 'Facebook'
],
- ]
+ ]
];
}
@@ -480,5 +478,4 @@ public function testMapUserException()
$mapUser->setAccessible(true);
$mapUser->invoke($this->SocialAuthenticate, null, $data);
}
-
}
diff --git a/tests/TestCase/Model/Behavior/SocialBehaviorTest.php b/tests/TestCase/Model/Behavior/SocialBehaviorTest.php
index 600b49465..33f700836 100644
--- a/tests/TestCase/Model/Behavior/SocialBehaviorTest.php
+++ b/tests/TestCase/Model/Behavior/SocialBehaviorTest.php
@@ -61,7 +61,7 @@ public function tearDown()
*/
public function testSocialLoginFacebookProvider($data, $options, $dataUser)
{
- $user = $this->Table->newEntity($dataUser, ['associated' => ['SocialAccounts']]);
+ $user = $this->Table->newEntity($dataUser, ['associated' => ['SocialAccounts']]);
$user->password = '$2y$10$0QzszaIEpW1pYpoKJVf4DeqEAHtg9whiLTX/l3TcHAoOLF1bC9U.6';
$this->Behavior->expects($this->once())
@@ -122,7 +122,7 @@ public function providerFacebookSocialLogin()
'link' => 'facebook-link',
'provider' => 'Facebook'
],
- 'options' => [
+ 'options' => [
'use_email' => true,
'validate_email' => true,
'token_expiration' => 3600
@@ -154,10 +154,9 @@ public function providerFacebookSocialLogin()
'activation_date' => '2016-01-20 15:45:09',
'active' => true,
]
- ]
+ ]
];
-
}
/**
@@ -179,7 +178,6 @@ public function testSocialLoginExistingReference($data, $options)
$result = $this->Behavior->socialLogin($data, $options);
$this->assertEquals($result->id, '00000000-0000-0000-0000-000000000002');
$this->assertTrue($result->active);
-
}
/**
@@ -194,7 +192,7 @@ public function providerFacebookSocialLoginExistingReference()
'id' => 'reference-2-1',
'provider' => 'Facebook'
],
- 'options' => [
+ 'options' => [
'use_email' => true,
'validate_email' => true,
'token_expiration' => 3600
@@ -212,7 +210,6 @@ public function providerFacebookSocialLoginExistingReference()
*/
public function testSocialLoginExistingNotActiveReference($data, $options)
{
-
$this->Behavior->expects($this->never())
->method('generateUniqueUsername');
@@ -222,7 +219,6 @@ public function testSocialLoginExistingNotActiveReference($data, $options)
$this->Behavior->expects($this->never())
->method('_updateActive');
$this->Behavior->socialLogin($data, $options);
-
}
/**
@@ -237,7 +233,7 @@ public function providerSocialLoginExistingAndNotActiveAccount()
'id' => 'reference-1-1234',
'provider' => 'Facebook'
],
- 'options' => [
+ 'options' => [
'use_email' => true,
'validate_email' => true,
'token_expiration' => 3600
@@ -255,7 +251,6 @@ public function providerSocialLoginExistingAndNotActiveAccount()
*/
public function testSocialLoginExistingReferenceNotActiveUser($data, $options)
{
-
$this->Behavior->expects($this->never())
->method('generateUniqueUsername');
@@ -265,7 +260,6 @@ public function testSocialLoginExistingReferenceNotActiveUser($data, $options)
$this->Behavior->expects($this->never())
->method('_updateActive');
$this->Behavior->socialLogin($data, $options);
-
}
/**
@@ -280,7 +274,7 @@ public function providerSocialLoginExistingAccountNotActiveUser()
'id' => 'reference-1-1234',
'provider' => 'Twitter'
],
- 'options' => [
+ 'options' => [
'use_email' => true,
'validate_email' => true,
'token_expiration' => 3600
@@ -320,7 +314,7 @@ public function providerFacebookSocialLoginNoEmail()
'link' => 'facebook-link',
'provider' => 'Facebook'
],
- 'options' => [
+ 'options' => [
'use_email' => true,
'validate_email' => true,
'token_expiration' => 3600
@@ -359,5 +353,4 @@ public function providerGenerateUsername()
];
}
-
}
diff --git a/tests/TestCase/Model/Table/UsersTableTest.php b/tests/TestCase/Model/Table/UsersTableTest.php
index c241e2a41..f9522fd60 100644
--- a/tests/TestCase/Model/Table/UsersTableTest.php
+++ b/tests/TestCase/Model/Table/UsersTableTest.php
@@ -27,7 +27,6 @@
*/
class UsersTableTest extends TestCase
{
-
/**
* Fixtures
*
@@ -184,7 +183,7 @@ public function testSocialLogin()
'email' => 'user-2@test.com',
'id' => 'reference-2-1',
'link' => 'link',
- 'raw' => [
+ 'raw' => [
'id' => 'reference-2-1',
'token' => 'token',
'first_name' => 'User 2',
@@ -216,7 +215,7 @@ public function testSocialLoginInactiveAccount()
'email' => 'hello@test.com',
'id' => 'reference-2-2',
'link' => 'link',
- 'raw' => [
+ 'raw' => [
'id' => 'reference-2-2',
'first_name' => 'User 2',
'gender' => 'female',
@@ -246,7 +245,7 @@ public function testSocialLoginCreateNewAccountWithNoCredentials()
'email' => 'user@test.com',
'id' => 'reference-not-existing',
'link' => 'link',
- 'raw' => [
+ 'raw' => [
'id' => 'reference-not-existing',
'first_name' => 'Not existing user',
'gender' => 'male',
@@ -278,7 +277,7 @@ public function testSocialLoginCreateNewAccount()
'link' => 'link',
'first_name' => 'First Name',
'last_name' => 'Last Name',
- 'raw' => [
+ 'raw' => [
'id' => 'no-existing-reference',
'first_name' => 'First Name',
'last_name' => 'Last Name',
From 03281aac7336b4644e0ff7040214640788a3a29b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Sat, 6 Feb 2016 17:43:18 +0000
Subject: [PATCH 0281/1397] fix docs about default social login disabled
---
Docs/Documentation/Configuration.md | 4 +++-
Docs/Documentation/Installation.md | 9 ++++++++-
Docs/Documentation/SocialAuthenticate.md | 2 +-
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/Docs/Documentation/Configuration.md b/Docs/Documentation/Configuration.md
index a37f68b0f..70ebecc19 100644
--- a/Docs/Documentation/Configuration.md
+++ b/Docs/Documentation/Configuration.md
@@ -10,9 +10,11 @@ config/bootstrap.php
```
Configure::write('Users.config', ['users']);
Plugin::load('CakeDC/Users', ['routes' => true, 'bootstrap' => true]);
+Configure::write('Users.Social.login', true); //to enable social login
```
Then in your config/users.php
+
```
'Opauth.providers' => [
'facebook' => [
@@ -102,7 +104,7 @@ NOTE: SOME keys were hidden in this doc page, please refer to `vendor/cakedc/use
],
'Social' => [
//enable social login
- 'login' => true,
+ 'login' => false,
],
//Avatar placeholder
'Avatar' => ['placeholder' => 'CakeDC/Users.avatar_placeholder.png'],
diff --git a/Docs/Documentation/Installation.md b/Docs/Documentation/Installation.md
index 3822254fa..6a5cafde6 100644
--- a/Docs/Documentation/Installation.md
+++ b/Docs/Documentation/Installation.md
@@ -5,7 +5,7 @@ Composer
------
```
-composer require cakedc/users:3.1.*
+composer require cakedc/users
```
if you want to use social login features...
@@ -16,7 +16,13 @@ composer require league/oauth2-facebook:*
composer require league/oauth2-instagram:*
composer require league/oauth2-google:*
composer require league/oauth2-linkedin:*
+```
+
+NOTE: you'll need to enable social login in your bootstrap.php file if you want to use it, social
+login is disabled by default. Check the [Configuration](Configuration.md) page for more details.
+```
+Configure::write('Users.Social.login', true); //to enable social login
```
Creating Required Tables
@@ -47,6 +53,7 @@ config/bootstrap.php
```
Configure::write('Users.config', ['users']);
Plugin::load('CakeDC/Users', ['routes' => true, 'bootstrap' => true]);
+Configure::write('Users.Social.login', true); //to enable social login
```
Then in your config/users.php
diff --git a/Docs/Documentation/SocialAuthenticate.md b/Docs/Documentation/SocialAuthenticate.md
index 6bcfefe20..bb3fd2929 100644
--- a/Docs/Documentation/SocialAuthenticate.md
+++ b/Docs/Documentation/SocialAuthenticate.md
@@ -27,7 +27,7 @@ Configure::write('Users', [
],
'Social' => [
//enable social login
- 'login' => true,
+ 'login' => false,
],
'Key' => [
'Session' => [
From 7e593c9c0ac599368434354b8e90948cccad6bb2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Sat, 6 Feb 2016 17:48:45 +0000
Subject: [PATCH 0282/1397] fix readme
---
README.md | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index c797056ef..4ceafd332 100644
--- a/README.md
+++ b/README.md
@@ -44,8 +44,8 @@ Another decision made was limiting the plugin dependencies on other packages as
Requirements
------------
-* CakePHP 3.1.*
-* PHP 5.4.16+
+* CakePHP 3.1+
+* PHP 5.4.16+ Note CakePHP 3.2 requires PHP 5.5 so 5.4 compatibility would be dropped sooner than later...
Documentation
-------------
@@ -55,11 +55,14 @@ For documentation, as well as tutorials, see the [Docs](Docs/Home.md) directory
Roadmap
------
+
+* 3.1.4 << you are here
+ * SocialAuthenticate refactored to drop Opauth in favor of Muffin/OAuth2 and league/oauth2
+* 3.1.3
+ * UserHelper improvements
* 3.1.2
- * Add Google authentication
- * Add Instagram authentication
- * Improve unit test coverage
-* YOU ARE HERE > 3.1.0 Migration to CakePHP 3.0
+ * Fixes in RBAC permission matchers
+* 3.1.0 Migration to CakePHP 3.0
* Unit test coverage improvements
* Refactor UsersTable to Behavior
* Add google authentication
From e877f201e5b10bf2cb73fa25d82a1069300d2842 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20M=2E=20Gonz=C3=A1lez=20Mart=C3=ADn?=
Date: Sat, 6 Feb 2016 17:50:55 +0000
Subject: [PATCH 0283/1397] Update .semver
---
.semver | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.semver b/.semver
index daa667f3f..abcaef42f 100644
--- a/.semver
+++ b/.semver
@@ -1,5 +1,5 @@
---
:major: 3
:minor: 1
-:patch: 0
+:patch: 4
:special: ''
From 755ee1a96d00422f8ac974b9b13c5e1d4e86aaef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Sun, 31 Jan 2016 13:40:30 +0000
Subject: [PATCH 0284/1397] add Owner rule class, to define ownership
permissions quickly
---
src/Auth/Rules/AbstractRule.php | 92 +++++++++
src/Auth/Rules/Owner.php | 72 +++++++
src/Auth/Rules/Rule.php | 27 +++
src/Auth/SimpleRbacAuthorize.php | 3 +
tests/Fixture/PostsFixture.php | 60 ++++++
tests/Fixture/PostsUsersFixture.php | 60 ++++++
tests/TestCase/Auth/Rules/OwnerTest.php | 261 ++++++++++++++++++++++++
tests/bootstrap.php | 4 +-
8 files changed, 578 insertions(+), 1 deletion(-)
create mode 100644 src/Auth/Rules/AbstractRule.php
create mode 100644 src/Auth/Rules/Owner.php
create mode 100644 src/Auth/Rules/Rule.php
create mode 100644 tests/Fixture/PostsFixture.php
create mode 100644 tests/Fixture/PostsUsersFixture.php
create mode 100644 tests/TestCase/Auth/Rules/OwnerTest.php
diff --git a/src/Auth/Rules/AbstractRule.php b/src/Auth/Rules/AbstractRule.php
new file mode 100644
index 000000000..f8955fbbc
--- /dev/null
+++ b/src/Auth/Rules/AbstractRule.php
@@ -0,0 +1,92 @@
+config($config);
+ }
+
+ /**
+ * Get a table from the alias, table object or inspecting the request for a default table
+ *
+ * @param Request $request request
+ * @param mixed $table table
+ * @return \Cake\ORM\Table
+ * @throw OutOfBoundsException if table alias is empty
+ */
+ protected function _getTable(Request $request, $table = null)
+ {
+ if (empty($table)) {
+ return $this->_getTableFromRequest($request);
+ }
+ if ($table instanceof Table) {
+ return $table;
+ }
+ return TableRegistry::get($table);
+ }
+
+ /**
+ * Inspect the request and try to retrieve a table based on the current controller
+ *
+ * @param Request $request request
+ * @return Table
+ * @throws OutOfBoundsException if table alias can't be extracted from request
+ */
+ protected function _getTableFromRequest(Request $request)
+ {
+ $plugin = Hash::get($request->params, 'plugin');
+ $controller = Hash::get($request->params, 'controller');
+ $modelClass = ($plugin ? $plugin . '.' : '') . $controller;
+
+ $this->modelFactory('Table', [$this->tableLocator(), 'get']);
+ if (empty($modelClass)) {
+ throw new OutOfBoundsException(__d('Users', 'Table alias is empty, please define a table alias, we could not extract a default table from the request'));
+ }
+ return $this->loadModel($modelClass);
+ }
+
+ /**
+ * Check the current entity is owned by the logged in user
+ *
+ * @param array $user Auth array with the logged in data
+ * @param string $role role of the user
+ * @param Request $request current request, used to get a default table if not provided
+ * @return bool
+ * @throws OutOfBoundsException if table is not found or it doesn't have the expected fields
+ */
+ abstract public function allowed(array $user, $role, Request $request);
+}
diff --git a/src/Auth/Rules/Owner.php b/src/Auth/Rules/Owner.php
new file mode 100644
index 000000000..68799892c
--- /dev/null
+++ b/src/Auth/Rules/Owner.php
@@ -0,0 +1,72 @@
+ 'user_id',
+ /*
+ * request key type to retrieve the table id, could be "params", "query", "data" to locate the table id
+ * example:
+ * yoursite.com/controller/action/XXX would be
+ * tableKeyType => 'params', 'tableIdParamsKey' => 'pass.0'
+ * yoursite.com/controlerr/action?post_id=XXX would be
+ * tableKeyType => 'query', 'tableIdParamsKey' => 'post_id'
+ * yoursite.com/controller/action [posted form with a field named post_id] would be
+ * tableKeyType => 'data', 'tableIdParamsKey' => 'post_id'
+ */
+ 'tableKeyType' => 'params',
+ // request->params key path to retrieve the owned table id
+ 'tableIdParamsKey' => 'pass.0',
+ /* define table to use or pick it from controller name defaults if null
+ * if null, table used will be based on current controller's default table
+ * if string, TableRegistry::get will be used
+ * if Table, the table object will be used
+ */
+ 'table' => null,
+ 'conditions' => [],
+ ];
+
+ /**
+ * {@inheritdoc}
+ */
+ public function allowed(array $user, $role, Request $request)
+ {
+ $table = $this->_getTable($request, $this->config('table'));
+ //retrieve table id from request
+ $id = Hash::get($request->{$this->config('tableKeyType')}, $this->config('tableIdParamsKey'));
+ $userId = Hash::get($user, 'id');
+
+ try {
+ if (!$table->hasField($this->config('ownerForeignKey'))) {
+ throw new OutOfBoundsException(__d('Users', 'Missing column {0} in table {1} while checking ownership permissions for user {2}', $this->config('ownerForeignKey'), $table->alias(), $userId));
+ }
+ } catch (Exception $ex) {
+ throw new OutOfBoundsException(__d('Users', 'Table {0} has no columns, please check the table exists. {1}', $table->alias(), $ex->getMessage()));
+ }
+ $conditions = array_merge([
+ $table->primaryKey() => $id,
+ $this->config('ownerForeignKey') => $userId
+ ], $this->config('conditions'));
+
+ return $table->exists($conditions);
+ }
+}
diff --git a/src/Auth/Rules/Rule.php b/src/Auth/Rules/Rule.php
new file mode 100644
index 000000000..7ba6c438d
--- /dev/null
+++ b/src/Auth/Rules/Rule.php
@@ -0,0 +1,27 @@
+_matchOrAsterisk($permission, 'controller', $controller) &&
$this->_matchOrAsterisk($permission, 'action', $action)) {
$allowed = Hash::get($permission, 'allowed');
+
if ($allowed === null) {
//allowed will be true by default
return true;
} elseif (is_callable($allowed)) {
return (bool)call_user_func($allowed, $user, $role, $request);
+ } elseif ($allowed instanceof \CakeDC\Users\Auth\Rules\AbstractRule) {
+ return $allowed->allowed($user, $role, $request);
} else {
return (bool)$allowed;
}
diff --git a/tests/Fixture/PostsFixture.php b/tests/Fixture/PostsFixture.php
new file mode 100644
index 000000000..fadeb7179
--- /dev/null
+++ b/tests/Fixture/PostsFixture.php
@@ -0,0 +1,60 @@
+ ['type' => 'uuid', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null],
+ 'title' => ['type' => 'string', 'length' => 255, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null],
+ 'user_id' => ['type' => 'uuid', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null],
+ '_constraints' => [
+ 'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []],
+ ],
+ '_options' => [
+ 'engine' => 'InnoDB',
+ 'collation' => 'utf8_general_ci'
+ ],
+ ];
+ // @codingStandardsIgnoreEnd
+
+ /**
+ * Records
+ *
+ * @var array
+ */
+ public $records = [
+ [
+ 'id' => '00000000-0000-0000-0000-000000000001',
+ 'title' => 'post-1',
+ 'user_id' => '00000000-0000-0000-0000-000000000001',
+ ],
+ [
+ 'id' => '00000000-0000-0000-0000-000000000002',
+ 'title' => 'post-2',
+ 'user_id' => '00000000-0000-0000-0000-000000000002',
+ ],
+ ];
+}
diff --git a/tests/Fixture/PostsUsersFixture.php b/tests/Fixture/PostsUsersFixture.php
new file mode 100644
index 000000000..9227398ab
--- /dev/null
+++ b/tests/Fixture/PostsUsersFixture.php
@@ -0,0 +1,60 @@
+ ['type' => 'uuid', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null],
+ 'user_id' => ['type' => 'uuid', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null],
+ 'post_id' => ['type' => 'uuid', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null],
+ '_constraints' => [
+ 'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []],
+ ],
+ '_options' => [
+ 'engine' => 'InnoDB',
+ 'collation' => 'utf8_general_ci'
+ ],
+ ];
+ // @codingStandardsIgnoreEnd
+
+ /**
+ * Records
+ *
+ * @var array
+ */
+ public $records = [
+ [
+ 'id' => '00000000-0000-0000-0000-000000000001',
+ 'user_id' => '00000000-0000-0000-0000-000000000001',
+ 'post_id' => '00000000-0000-0000-0000-000000000001',
+ ],
+ [
+ 'id' => '00000000-0000-0000-0000-000000000002',
+ 'user_id' => '00000000-0000-0000-0000-000000000002',
+ 'post_id' => '00000000-0000-0000-0000-000000000002',
+ ],
+ ];
+}
diff --git a/tests/TestCase/Auth/Rules/OwnerTest.php b/tests/TestCase/Auth/Rules/OwnerTest.php
new file mode 100644
index 000000000..e98b8f0c8
--- /dev/null
+++ b/tests/TestCase/Auth/Rules/OwnerTest.php
@@ -0,0 +1,261 @@
+Owner = new Owner();
+ $this->request = $this->getMockBuilder('\Cake\Network\Request')
+ ->getMock();
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ public function tearDown()
+ {
+ unset($this->Owner);
+ }
+
+ /**
+ * test
+ *
+ * @return void
+ */
+ public function testAllowed()
+ {
+ $this->request->params = [
+ 'plugin' => 'CakeDC/Users',
+ 'controller' => 'Posts',
+ 'pass' => ['00000000-0000-0000-0000-000000000001']
+ ];
+ $user = [
+ 'id' => '00000000-0000-0000-0000-000000000001',
+ ];
+ $this->assertTrue($this->Owner->allowed($user, 'user', $this->request));
+ }
+
+ /**
+ * test
+ *
+ * @return void
+ */
+ public function testAllowedUsingTableAlias()
+ {
+ $this->Owner = new Owner([
+ 'table' => 'Posts'
+ ]);
+ $this->request->params = [
+ 'pass' => ['00000000-0000-0000-0000-000000000001']
+ ];
+ $user = [
+ 'id' => '00000000-0000-0000-0000-000000000001',
+ ];
+ $this->assertTrue($this->Owner->allowed($user, 'user', $this->request));
+ }
+
+ /**
+ * test
+ *
+ * @return void
+ */
+ public function testAllowedUsingTableInstance()
+ {
+ $this->Owner = new Owner([
+ 'table' => TableRegistry::get('CakeDC/Users.Posts'),
+ ]);
+ $this->request->params = [
+ 'pass' => ['00000000-0000-0000-0000-000000000001']
+ ];
+ $user = [
+ 'id' => '00000000-0000-0000-0000-000000000001',
+ ];
+ $this->assertTrue($this->Owner->allowed($user, 'user', $this->request));
+ }
+
+ /**
+ * test
+ *
+ * @return void
+ * @expectedException \OutOfBoundsException
+ * @expectedExceptionMessage Table alias is empty, please define a table alias, we could not extract a default table from the request
+ */
+ public function testAllowedShouldThrowExceptionBecauseEmptyAliasFromRequest()
+ {
+ $this->request->params = [
+ 'pass' => ['00000000-0000-0000-0000-000000000001']
+ ];
+ $user = [
+ 'id' => '00000000-0000-0000-0000-000000000001',
+ ];
+ $this->Owner->allowed($user, 'user', $this->request);
+ }
+
+ /**
+ * test
+ *
+ * @return void
+ * @expectedException \OutOfBoundsException
+ * @expectedExceptionMessage Missing column column_not_found in table Posts while checking ownership permissions for user 00000000-0000-0000-0000-000000000001
+ */
+ public function testAllowedShouldThrowExceptionBecauseForeignKeyNotPresentInTable()
+ {
+ $this->Owner = new Owner([
+ 'table' => TableRegistry::get('CakeDC/Users.Posts'),
+ 'ownerForeignKey' => 'column_not_found',
+ ]);
+ $this->request->params = [
+ 'pass' => ['00000000-0000-0000-0000-000000000001']
+ ];
+ $user = [
+ 'id' => '00000000-0000-0000-0000-000000000001',
+ ];
+ $this->Owner->allowed($user, 'user', $this->request);
+ }
+
+ /**
+ * test
+ *
+ * @return void
+ */
+ public function testNotAllowedBecauseNotOwner()
+ {
+ $this->request->params = [
+ 'plugin' => 'CakeDC/Users',
+ 'controller' => 'Posts',
+ 'pass' => ['00000000-0000-0000-0000-000000000002']
+ ];
+ $user = [
+ 'id' => '00000000-0000-0000-0000-000000000001',
+ ];
+ $this->assertFalse($this->Owner->allowed($user, 'user', $this->request));
+ }
+
+ /**
+ * test
+ *
+ * @return void
+ */
+ public function testNotAllowedBecauseUserNotFound()
+ {
+ $this->request->params = [
+ 'plugin' => 'CakeDC/Users',
+ 'controller' => 'Posts',
+ 'pass' => ['00000000-0000-0000-0000-000000000002']
+ ];
+ $user = [
+ 'id' => 'not-found',
+ ];
+ $this->assertFalse($this->Owner->allowed($user, 'user', $this->request));
+ }
+
+ /**
+ * test
+ *
+ * @return void
+ */
+ public function testNotAllowedBecausePostNotFound()
+ {
+ $this->request->params = [
+ 'plugin' => 'CakeDC/Users',
+ 'controller' => 'Posts',
+ 'pass' => ['not-found']
+ ];
+ $user = [
+ 'id' => '00000000-0000-0000-0000-000000000001',
+ ];
+ $this->assertFalse($this->Owner->allowed($user, 'user', $this->request));
+ }
+
+ /**
+ * test
+ *
+ * @return void
+ * @expectedException \OutOfBoundsException
+ * @expectedExceptionMessage Table NoDefaultTable has no columns, please check the table exists. Cannot describe no_default_table. It has 0 columns.
+ */
+ public function testNotAllowedBecauseNoDefaultTable()
+ {
+ $this->request->params = [
+ 'plugin' => 'CakeDC/Users',
+ 'controller' => 'NoDefaultTable',
+ 'pass' => ['00000000-0000-0000-0000-000000000001']
+ ];
+ $user = [
+ 'id' => '00000000-0000-0000-0000-000000000001',
+ ];
+ $this->assertFalse($this->Owner->allowed($user, 'user', $this->request));
+ }
+
+ /**
+ * Test using the Owner rule in a belongsToMany association
+ * Posts belongsToMany Users
+ * @return void
+ */
+ public function testAllowedBelongsToMany()
+ {
+ $this->Owner = new Owner([
+ 'table' => 'PostsUsers'
+ ]);
+ $this->request->params = [
+ 'plugin' => 'CakeDC/Users',
+ 'controller' => 'IsNotUsed',
+ 'pass' => ['00000000-0000-0000-0000-000000000001']
+ ];
+ $user = [
+ 'id' => '00000000-0000-0000-0000-000000000001',
+ ];
+ $this->assertTrue($this->Owner->allowed($user, 'user', $this->request));
+ }
+
+ /**
+ * Test using the Owner rule in a belongsToMany association
+ * Posts belongsToMany Users
+ * @return void
+ */
+ public function testNotAllowedBelongsToMany()
+ {
+ $this->Owner = new Owner([
+ 'table' => 'PostsUsers'
+ ]);
+ $this->request->params = [
+ 'plugin' => 'CakeDC/Users',
+ 'controller' => 'IsNotUsed',
+ 'pass' => ['00000000-0000-0000-0000-000000000002']
+ ];
+ $user = [
+ 'id' => '00000000-0000-0000-0000-000000000001',
+ ];
+ $this->assertFalse($this->Owner->allowed($user, 'user', $this->request));
+ }
+}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index b0bbdb56c..d676a0a80 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -20,7 +20,9 @@
unset($findRoot);
chdir($root);
-define('DS', DIRECTORY_SEPARATOR);
+if (!defined('DS')) {
+ define('DS', DIRECTORY_SEPARATOR);
+}
define('ROOT', $root);
define('APP_DIR', 'App');
define('WEBROOT_DIR', 'webroot');
From ff96108cde2e3bf59ef2a15203de354811879dd3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Mon, 8 Feb 2016 17:31:34 +0000
Subject: [PATCH 0285/1397] minor fixes in tests
---
src/Auth/Rules/Owner.php | 2 +-
tests/TestCase/Auth/Rules/OwnerTest.php | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/Auth/Rules/Owner.php b/src/Auth/Rules/Owner.php
index 68799892c..0f52a1338 100644
--- a/src/Auth/Rules/Owner.php
+++ b/src/Auth/Rules/Owner.php
@@ -60,7 +60,7 @@ public function allowed(array $user, $role, Request $request)
throw new OutOfBoundsException(__d('Users', 'Missing column {0} in table {1} while checking ownership permissions for user {2}', $this->config('ownerForeignKey'), $table->alias(), $userId));
}
} catch (Exception $ex) {
- throw new OutOfBoundsException(__d('Users', 'Table {0} has no columns, please check the table exists. {1}', $table->alias(), $ex->getMessage()));
+ throw new OutOfBoundsException(__d('Users', 'Missing column {0} in table {1} while checking ownership permissions for user {2}', $this->config('ownerForeignKey'), $table->alias(), $userId));
}
$conditions = array_merge([
$table->primaryKey() => $id,
diff --git a/tests/TestCase/Auth/Rules/OwnerTest.php b/tests/TestCase/Auth/Rules/OwnerTest.php
index e98b8f0c8..aa320cf36 100644
--- a/tests/TestCase/Auth/Rules/OwnerTest.php
+++ b/tests/TestCase/Auth/Rules/OwnerTest.php
@@ -174,7 +174,7 @@ public function testNotAllowedBecauseUserNotFound()
'pass' => ['00000000-0000-0000-0000-000000000002']
];
$user = [
- 'id' => 'not-found',
+ 'id' => '99999999-0000-0000-0000-000000000000',
];
$this->assertFalse($this->Owner->allowed($user, 'user', $this->request));
}
@@ -189,7 +189,7 @@ public function testNotAllowedBecausePostNotFound()
$this->request->params = [
'plugin' => 'CakeDC/Users',
'controller' => 'Posts',
- 'pass' => ['not-found']
+ 'pass' => ['99999999-0000-0000-0000-000000000000'] //not found
];
$user = [
'id' => '00000000-0000-0000-0000-000000000001',
@@ -202,7 +202,7 @@ public function testNotAllowedBecausePostNotFound()
*
* @return void
* @expectedException \OutOfBoundsException
- * @expectedExceptionMessage Table NoDefaultTable has no columns, please check the table exists. Cannot describe no_default_table. It has 0 columns.
+ * @expectedExceptionMessage Missing column user_id in table NoDefaultTable while checking ownership permissions for user 00000000-0000-0000-0000-000000000001
*/
public function testNotAllowedBecauseNoDefaultTable()
{
From a39f507cc88e4a1fd9b0d5662caeb0f2f021cf02 Mon Sep 17 00:00:00 2001
From: Alejandro Ibarra
Date: Mon, 8 Feb 2016 14:18:54 -0500
Subject: [PATCH 0286/1397] Fixing new social login changes
---
Docs/Documentation/Installation.md | 1 -
composer.json | 35 ++-
config/bootstrap.php | 13 +-
config/routes.php | 15 +-
config/users.php | 11 +-
.../Exception/InvalidProviderException.php | 10 +
.../Exception/InvalidSettingsException.php | 10 +
.../MissingEventListenerException.php | 9 +
.../MissingProviderConfigurationException.php | 10 +
src/Auth/SocialAuthenticate.php | 263 +++++++++++++++++-
src/Controller/Traits/LoginTrait.php | 11 +-
src/Controller/Traits/SocialTrait.php | 1 +
src/Model/Table/SocialAccountsTable.php | 1 -
13 files changed, 358 insertions(+), 32 deletions(-)
create mode 100644 src/Auth/Exception/InvalidProviderException.php
create mode 100644 src/Auth/Exception/InvalidSettingsException.php
create mode 100644 src/Auth/Exception/MissingEventListenerException.php
create mode 100644 src/Auth/Exception/MissingProviderConfigurationException.php
diff --git a/Docs/Documentation/Installation.md b/Docs/Documentation/Installation.md
index 6a5cafde6..0e6e89caa 100644
--- a/Docs/Documentation/Installation.md
+++ b/Docs/Documentation/Installation.md
@@ -11,7 +11,6 @@ composer require cakedc/users
if you want to use social login features...
```
-composer require Muffin/OAuth2:*
composer require league/oauth2-facebook:*
composer require league/oauth2-instagram:*
composer require league/oauth2-google:*
diff --git a/composer.json b/composer.json
index dfc76803d..436ed31ed 100644
--- a/composer.json
+++ b/composer.json
@@ -2,20 +2,45 @@
"name": "cakedc/users",
"description": "Users plugin for CakePHP 3.1",
"type": "cakephp-plugin",
+ "keywords": [
+ "cakephp",
+ "oauth2",
+ "auth",
+ "authentication",
+ "cakedc"
+ ],
+ "homepage": "https://github.com/CakeDC/users",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "CakeDC",
+ "homepage": "http://www.cakedc.com",
+ "role": "Author"
+ },
+ {
+ "name": "Others",
+ "homepage": "https://github.com/CakeDC/users/graphs/contributors"
+ }
+ ],
+ "support": {
+ "issues": "https://github.com/CakeDC/users/issues",
+ "source": "https://github.com/CakeDC/users"
+ },
"require": {
"php": ">=5.4.16",
"cakephp/cakephp": "~3.1",
- "muffin/oauth2": "dev-master",
- "league/oauth1-client": "@stable"
},
"require-dev": {
"phpunit/phpunit": "*",
"cakephp/cakephp-codesniffer": "^2.0"
},
"suggest": {
- "league/oauth2-facebook": "Provide Social Authentication with Facebook",
- "league/oauth2-instagram": "Provide Social Authentication with Instagram",
- "google/recaptcha": "Provide reCAPTCHA validation for registration form"
+ "league/oauth1-client": "Provides Social Authentication with Twitter",
+ "league/oauth2-facebook": "Provides Social Authentication with Facebook",
+ "league/oauth2-instagram": "Provides Social Authentication with Instagram",
+ "league/oauth2-google": "Provides Social Authentication with Google+",
+ "league/oauth2-linkedin": "Provides Social Authentication with LinkedIn",
+ "google/recaptcha": "Provides reCAPTCHA validation for registration form"
},
"autoload": {
"psr-4": {
diff --git a/config/bootstrap.php b/config/bootstrap.php
index 28400af47..f931659c4 100644
--- a/config/bootstrap.php
+++ b/config/bootstrap.php
@@ -15,6 +15,7 @@
use Cake\Core\Plugin;
use Cake\Event\EventManager;
use Cake\ORM\TableRegistry;
+use Cake\Routing\Router;
Configure::load('CakeDC/Users.users');
collection((array)Configure::read('Users.config'))->each(function ($file) {
@@ -27,9 +28,19 @@
if (Configure::read('Users.Social.login') && php_sapi_name() != 'cli') {
try {
- Plugin::load('Muffin/OAuth2');
EventManager::instance()->on(\CakeDC\Users\Controller\Component\UsersAuthComponent::EVENT_FAILED_SOCIAL_LOGIN, [new \CakeDC\Users\Controller\UsersController(), 'failedSocialLoginListener']);
} catch (MissingPluginException $e) {
Log::error($e->getMessage());
}
}
+
+$oauthPath = Configure::read('OAuth.path');
+if (is_array($oauthPath)) {
+ Router::scope('/auth', function ($routes) use ($oauthPath) {
+ $routes->connect(
+ '/:provider',
+ $oauthPath,
+ ['provider' => implode('|', array_keys(Configure::read('OAuth.providers')))]
+ );
+ });
+}
\ No newline at end of file
diff --git a/config/routes.php b/config/routes.php
index 41dccc94b..191175c95 100644
--- a/config/routes.php
+++ b/config/routes.php
@@ -10,19 +10,14 @@
*/
use Cake\Core\Configure;
use Cake\Routing\Router;
+
Router::plugin('CakeDC/Users', ['path' => '/users'], function ($routes) {
$routes->fallbacks('DashedRoute');
});
-$oauthPath = Configure::read('OAuth.path');
-if (is_array($oauthPath)) {
- Router::scope('/auth', function ($routes) use ($oauthPath) {
- $routes->connect(
- '/:provider',
- $oauthPath,
- ['provider' => implode('|', array_keys(Configure::read('OAuth.providers')))]
- );
- });
-}
+
+//if (!Configure::check('OAuth.path')) {
+// Configure::load('CakeDC/Users.users');
+//}
Router::connect('/auth/twitter', [
'plugin' => 'CakeDC/Users',
'controller' => 'Users',
diff --git a/config/users.php b/config/users.php
index 616c33606..edc5e2433 100644
--- a/config/users.php
+++ b/config/users.php
@@ -10,6 +10,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
use Cake\Core\Configure;
+use Cake\Routing\Router;
$config = [
'Users' => [
@@ -107,19 +108,27 @@
'facebook' => [
'className' => 'League\OAuth2\Client\Provider\Facebook',
'options' => [
- 'graphApiVersion' => 'v2.5'
+ 'graphApiVersion' => 'v2.5',
+ 'redirectUri' => Router::url('/auth/facebook', true)
]
],
'linkedIn' => [
'className' => 'League\OAuth2\Client\Provider\LinkedIn',
+ 'options' => [
+ 'redirectUri' => Router::url('/auth/linkedIn', true)
+ ]
],
'instagram' => [
'className' => 'League\OAuth2\Client\Provider\Instagram',
+ 'options' => [
+ 'redirectUri' => Router::url('/auth/instagram', true)
+ ]
],
'google' => [
'className' => 'League\OAuth2\Client\Provider\Google',
'options' => [
'userFields' => ['url', 'aboutMe'],
+ 'redirectUri' => Router::url('/auth/google', true)
]
],
],
diff --git a/src/Auth/Exception/InvalidProviderException.php b/src/Auth/Exception/InvalidProviderException.php
new file mode 100644
index 000000000..1825d475c
--- /dev/null
+++ b/src/Auth/Exception/InvalidProviderException.php
@@ -0,0 +1,10 @@
+normalizeConfig(array_merge($config, $oauthConfig));
+ parent::__construct($registry, $config);
+ }
+
+ /**
+ * Normalizes providers' configuration.
+ *
+ * @param array $config Array of config to normalize.
+ * @return array
+ * @throws \Exception
+ */
+ public function normalizeConfig(array $config)
+ {
+ $config = Hash::merge((array)Configure::read('OAuth2'), $config);
+
+ if (empty($config['providers'])) {
+ throw new MissingProviderConfigurationException();
+ }
+
+ array_walk($config['providers'], [$this, '_normalizeConfig'], $config);
+ return $config;
+ }
+
+ /**
+ * Callback to loop through config values.
+ *
+ * @param array $config Configuration.
+ * @param string $alias Provider's alias (key) in configuration.
+ * @param array $parent Parent configuration.
+ * @return void
+ */
+ protected function _normalizeConfig(&$config, $alias, $parent)
+ {
+ unset($parent['providers']);
+
+ $defaults = [
+ 'className' => null,
+ 'options' => [],
+ 'collaborators' => [],
+ 'mapFields' => [],
+ ] + $parent + $this->_defaultConfig;
+
+ $config = array_intersect_key($config, $defaults);
+ $config += $defaults;
+
+ array_walk($config, [$this, '_validateConfig']);
+
+ foreach (['options', 'collaborators'] as $key) {
+ if (empty($parent[$key]) || empty($config[$key])) {
+ continue;
+ }
+
+ $config[$key] = array_merge($parent[$key], $config[$key]);
+ }
+ }
+
+ /**
+ * Validates the configuration.
+ *
+ * @param mixed $value Value.
+ * @param string $key Key.
+ * @return void
+ * @throws \Muffin\OAuth2\Auth\Exception\InvalidProviderException
+ * @throws \Muffin\OAuth2\Auth\Exception\InvalidSettingsException
+ */
+ protected function _validateConfig(&$value, $key)
+ {
+ if ($key === 'className' && !class_exists($value)) {
+ throw new InvalidProviderException([$value]);
+ } elseif (!is_array($value) && in_array($key, ['options', 'collaborators'])) {
+ throw new InvalidSettingsException([$key]);
+ }
+ }
+
+ /**
+ * Get a user based on information in the request.
+ *
+ * @param \Cake\Network\Request $request Request object.
+ * @param \Cake\Network\Response $response Response object.
+ * @return bool
+ * @throws \RuntimeException If the `CakeDC/Users/OAuth2.newUser` event is missing or returns empty.
+ */
+ public function authenticate(Request $request, Response $response)
+ {
+ return $this->getUser($request);
+ }
+
+ /**
+ * Authenticates with OAuth2 provider by getting an access token and
+ * retrieving the authorized user's profile data.
+ *
+ * @param \Cake\Network\Request $request Request object.
+ * @return array|bool
+ */
+ protected function _authenticate(Request $request)
+ {
+ if (!$this->_validate($request)) {
+ return false;
+ }
+
+ $provider = $this->provider($request);
+ $code = $request->query('code');
+
+ try {
+ $token = $provider->getAccessToken('authorization_code', compact('code'));
+ return compact('token') + $provider->getResourceOwner($token)->toArray();
+ } catch (\Exception $e) {
+ return false;
+ }
+ }
+
+ /**
+ * Validates OAuth2 request.
+ *
+ * @param \Cake\Network\Request $request Request object.
+ * @return bool
+ */
+ protected function _validate(Request $request)
+ {
+ if (!array_key_exists('code', $request->query) || !$this->provider($request)) {
+ return false;
+ }
+
+ $session = $request->session();
+ $sessionKey = 'oauth2state';
+ $state = $request->query('state');
+
+ if ($this->config('options.state') &&
+ (!$state || $state !== $session->read($sessionKey))) {
+ $session->delete($sessionKey);
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Maps raw provider's user profile data to local user's data schema.
+ *
+ * @param array $data Raw user data.
+ * @return array
+ */
+ protected function _map($data)
+ {
+ if (!$map = $this->config('mapFields')) {
+ return $data;
+ }
+
+ foreach ($map as $dst => $src) {
+ $data[$dst] = $data[$src];
+ unset($data[$src]);
+ }
+
+ return $data;
+ }
+
+ /**
+ * Handles unauthenticated access attempts. Will automatically forward to the
+ * requested provider's authorization URL to let the user grant access to the
+ * application.
+ *
+ * @param \Cake\Network\Request $request Request object.
+ * @param \Cake\Network\Response $response Response object.
+ * @return \Cake\Network\Response|null
+ */
+ public function unauthenticated(Request $request, Response $response)
+ {
+ $provider = $this->provider($request);
+ if (empty($provider) || !empty($request->query['code'])) {
+ return null;
+ }
+
+ if ($this->config('options.state')) {
+ $request->session()->write('oauth2state', $provider->getState());
+ }
+
+ $response->location($provider->getAuthorizationUrl());
+ return $response;
+ }
+
+ /**
+ * Returns the `$request`-ed provider.
+ *
+ * @param \Cake\Network\Request $request Current HTTP request.
+ * @return \League\Oauth2\Client\Provider\GenericProvider|false
+ */
+ public function provider(Request $request)
+ {
+ if (!$alias = $request->param('provider')) {
+ return false;
+ }
+
+ if (empty($this->_provider)) {
+ $this->_provider = $this->_getProvider($alias);
+ }
+
+ return $this->_provider;
+ }
+
+ /**
+ * Instantiates provider object.
+ *
+ * @param string $alias of the provider.
+ * @return \League\Oauth2\Client\Provider\GenericProvider
+ */
+ protected function _getProvider($alias)
+ {
+ if (!$config = $this->config('providers.' . $alias)) {
+ return false;
+ }
+
+ $this->config($config);
+
+ if (is_object($config) && $config instanceof AbstractProvider) {
+ return $config;
+ }
+
+ $class = $config['className'];
+ return new $class($config['options'], $config['collaborators']);
}
/**
@@ -66,14 +302,17 @@ protected function _touch(array $data)
} catch (MissingEmailException $ex) {
$exception = $ex;
}
-
if (!empty($exception)) {
- $event = UsersAuthComponent::EVENT_FAILED_SOCIAL_LOGIN;
$args = ['exception' => $exception, 'rawData' => $data];
- $event = $this->dispatchEvent($event, $args);
- if ($exception instanceof MissingEmailException && $data['provider'] == SocialAccountsTable::PROVIDER_TWITTER) {
- throw $exception;
+ $event = new Event(UsersAuthComponent::EVENT_FAILED_SOCIAL_LOGIN, $args);
+ $event = EventManager::instance()->dispatch($event);
+// if ($data['provider'] === SocialAccountsTable::PROVIDER_TWITTER) {
+// throw $exception;
+// }
+ if (method_exists($this->_registry->getController(), 'failedSocialLogin')) {
+ $this->_registry->getController()->failedSocialLogin($exception, $data, true);
}
+
return $event->result;
}
@@ -88,7 +327,7 @@ protected function _touch(array $data)
*
* @param \Cake\Network\Request $request Request object.
* @return mixed Either false or an array of user information
- * @throws \RuntimeException If the `Muffin/OAuth2.newUser` event is missing or returns empty.
+ * @throws \RuntimeException If the `CakeDC/Users/OAuth2.newUser` event is missing or returns empty.
*/
public function getUser(Request $request)
{
@@ -110,6 +349,9 @@ public function getUser(Request $request)
$provider = $this->_getProviderName($request);
$user = $this->_mapUser($provider, $rawData);
+ if ($user['provider'] === SocialAccountsTable::PROVIDER_TWITTER) {
+ $request->session()->write(Configure::read('Users.Key.Session.social'), $user);
+ }
}
if (!$user || !$this->config('userModel')) {
@@ -119,6 +361,7 @@ public function getUser(Request $request)
if (!$result = $this->_touch($user)) {
return false;
}
+ $request->session()->delete(Configure::read('Users.Key.Session.social'));
return $result;
}
diff --git a/src/Controller/Traits/LoginTrait.php b/src/Controller/Traits/LoginTrait.php
index f70476b18..493257e22 100644
--- a/src/Controller/Traits/LoginTrait.php
+++ b/src/Controller/Traits/LoginTrait.php
@@ -18,6 +18,7 @@
use Cake\Core\Configure;
use Cake\Event\Event;
use Cake\Network\Exception\NotFoundException;
+use CakeDC\Users\Model\Table\SocialAccountsTable;
use League\OAuth1\Client\Server\Twitter;
/**
@@ -63,8 +64,9 @@ public function twitterLogin()
} catch (MissingEmailException $ex) {
$exception = $ex;
}
+
if (!empty($exception)) {
- return $this->failedSocialLogin($exception, $this->request->session()->read(Configure::read('Users.Key.Session.social')));
+ return $this->failedSocialLogin($exception, $this->request->session()->read(Configure::read('Users.Key.Session.social')), true);
}
} else {
$temporaryCredentials = $server->getTemporaryCredentials();
@@ -78,7 +80,7 @@ public function twitterLogin()
*/
public function failedSocialLoginListener(Event $event)
{
- $this->failedSocialLogin($event->data['exception'], $event->data['rawData'], true);
+ return $this->failedSocialLogin($event->data['exception'], $event->data['rawData'], true);
}
/**
@@ -90,6 +92,7 @@ public function failedSocialLoginListener(Event $event)
public function failedSocialLogin($exception, $data, $flash = false)
{
$msg = __d('Users', 'Issues trying to log in with your social account');
+
if (isset($exception)) {
if ($exception instanceof MissingEmailException) {
if ($flash) {
@@ -105,8 +108,10 @@ public function failedSocialLogin($exception, $data, $flash = false)
}
}
if ($flash) {
+ $this->Auth->config('authError', $msg);
+ $this->Auth->config('flash.params', ['class' => 'success']);
$this->request->session()->delete(Configure::read('Users.Key.Session.social'));
- $this->Flash->success($msg);
+ $this->Flash->success(__d('Users', $msg));
}
return $this->redirect(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login']);
}
diff --git a/src/Controller/Traits/SocialTrait.php b/src/Controller/Traits/SocialTrait.php
index bb03f187b..05a90f957 100644
--- a/src/Controller/Traits/SocialTrait.php
+++ b/src/Controller/Traits/SocialTrait.php
@@ -31,6 +31,7 @@ public function socialEmail()
if (!$this->request->session()->check(Configure::read('Users.Key.Session.social'))) {
throw new NotFoundException();
}
+ $this->request->session()->delete('Flash.auth');
if ($this->request->is('post')) {
$validPost = $this->_validateRegisterPost();
diff --git a/src/Model/Table/SocialAccountsTable.php b/src/Model/Table/SocialAccountsTable.php
index f753d0e81..5e86bb046 100644
--- a/src/Model/Table/SocialAccountsTable.php
+++ b/src/Model/Table/SocialAccountsTable.php
@@ -112,7 +112,6 @@ public function validationDefault(Validator $validator)
*/
public function buildRules(RulesChecker $rules)
{
- $rules->add($rules->isUnique(['username']));
$rules->add($rules->existsIn(['user_id'], 'Users'));
return $rules;
}
From 2a80d7c4ff81d3607752bdd77291527d4b2f51be Mon Sep 17 00:00:00 2001
From: Alejandro Ibarra
Date: Mon, 8 Feb 2016 15:06:44 -0500
Subject: [PATCH 0287/1397] Remove out commented code
---
src/Auth/SocialAuthenticate.php | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/Auth/SocialAuthenticate.php b/src/Auth/SocialAuthenticate.php
index d567ef4fa..2ac88c9b5 100755
--- a/src/Auth/SocialAuthenticate.php
+++ b/src/Auth/SocialAuthenticate.php
@@ -306,9 +306,6 @@ protected function _touch(array $data)
$args = ['exception' => $exception, 'rawData' => $data];
$event = new Event(UsersAuthComponent::EVENT_FAILED_SOCIAL_LOGIN, $args);
$event = EventManager::instance()->dispatch($event);
-// if ($data['provider'] === SocialAccountsTable::PROVIDER_TWITTER) {
-// throw $exception;
-// }
if (method_exists($this->_registry->getController(), 'failedSocialLogin')) {
$this->_registry->getController()->failedSocialLogin($exception, $data, true);
}
From eed74d010c72f2650e82d954c4da278f9b138694 Mon Sep 17 00:00:00 2001
From: Alejandro Ibarra
Date: Mon, 8 Feb 2016 16:35:36 -0500
Subject: [PATCH 0288/1397] Fix google for non google+ users
---
src/Auth/Social/Mapper/AbstractMapper.php | 1 +
src/Auth/Social/Mapper/Google.php | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git a/src/Auth/Social/Mapper/AbstractMapper.php b/src/Auth/Social/Mapper/AbstractMapper.php
index 0a738b0d6..ac045815d 100644
--- a/src/Auth/Social/Mapper/AbstractMapper.php
+++ b/src/Auth/Social/Mapper/AbstractMapper.php
@@ -108,6 +108,7 @@ protected function _map()
'expires' => is_array($token) ? Hash::get($token, 'expires') : $token->getExpires(),
];
$result['raw'] = $this->_rawData;
+
return $result;
}
}
diff --git a/src/Auth/Social/Mapper/Google.php b/src/Auth/Social/Mapper/Google.php
index f5ba5a1ec..843cf75bb 100644
--- a/src/Auth/Social/Mapper/Google.php
+++ b/src/Auth/Social/Mapper/Google.php
@@ -10,6 +10,7 @@
*/
namespace CakeDC\Users\Auth\Social\Mapper;
+use Cake\Utility\Hash;
/**
* Google Mapper
@@ -30,4 +31,12 @@ class Google extends AbstractMapper
'bio' => 'aboutMe',
'link' => 'url'
];
+
+ /**
+ * @return string
+ */
+ protected function _link()
+ {
+ return Hash::get($this->_rawData, $this->_mapFields['link']) ?: '#';
+ }
}
From d2b220bbd8e922a75b3084709f5bcf3be5cc623a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Tue, 9 Feb 2016 10:32:00 +0000
Subject: [PATCH 0289/1397] replace and use interface, as it should be
---
src/Auth/SimpleRbacAuthorize.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/Auth/SimpleRbacAuthorize.php b/src/Auth/SimpleRbacAuthorize.php
index ab38d814b..85c5913c2 100644
--- a/src/Auth/SimpleRbacAuthorize.php
+++ b/src/Auth/SimpleRbacAuthorize.php
@@ -19,6 +19,7 @@
use Cake\Network\Request;
use Cake\Utility\Hash;
use Cake\Utility\Inflector;
+use CakeDC\Users\Auth\Rules\Rule;
use Psr\Log\LogLevel;
/**
@@ -213,8 +214,8 @@ protected function _matchRule($permission, $user, $role, $request)
return true;
} elseif (is_callable($allowed)) {
return (bool)call_user_func($allowed, $user, $role, $request);
- } elseif ($allowed instanceof \CakeDC\Users\Auth\Rules\AbstractRule) {
- return $allowed->allowed($user, $role, $request);
+ } elseif ($allowed instanceof Rule) {
+ return (bool)$allowed->allowed($user, $role, $request);
} else {
return (bool)$allowed;
}
From fa2eb52d5b5da6d122e214fd36379fa2c65d887b Mon Sep 17 00:00:00 2001
From: Alejandro Ibarra
Date: Tue, 9 Feb 2016 08:26:05 -0500
Subject: [PATCH 0290/1397] Adding inspired
---
Docs/Documentation/SocialAuthenticate.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Docs/Documentation/SocialAuthenticate.md b/Docs/Documentation/SocialAuthenticate.md
index bb3fd2929..3da9c7e89 100644
--- a/Docs/Documentation/SocialAuthenticate.md
+++ b/Docs/Documentation/SocialAuthenticate.md
@@ -80,3 +80,5 @@ $this->User->twitterLogin();
We recommend the use of [Bootstrap Social](http://lipis.github.io/bootstrap-social/) in order to automatically apply styles to buttons. Anyway you can always add your own style to the buttons.
+Social Authentication was inspired by [UseMuffin/OAuth2](https://github.com/UseMuffin/OAuth2) library.
+
From f145e81936cd01eda64c7fccc4a84c1dadd2b65e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Tue, 9 Feb 2016 13:30:56 +0000
Subject: [PATCH 0291/1397] fix broken tests
---
composer.json | 8 ++++++--
tests/TestCase/Auth/SocialAuthenticateTest.php | 11 ++++++-----
tests/bootstrap.php | 2 ++
3 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/composer.json b/composer.json
index 436ed31ed..ec3d24a3f 100644
--- a/composer.json
+++ b/composer.json
@@ -28,11 +28,15 @@
},
"require": {
"php": ">=5.4.16",
- "cakephp/cakephp": "~3.1",
+ "cakephp/cakephp": "~3.1"
},
"require-dev": {
"phpunit/phpunit": "*",
- "cakephp/cakephp-codesniffer": "^2.0"
+ "cakephp/cakephp-codesniffer": "^2.0",
+ "league/oauth2-facebook": "@stable",
+ "league/oauth2-instagram": "@stable",
+ "league/oauth2-google": "@stable",
+ "league/oauth2-linkedin": "@stable"
},
"suggest": {
"league/oauth1-client": "Provides Social Authentication with Twitter",
diff --git a/tests/TestCase/Auth/SocialAuthenticateTest.php b/tests/TestCase/Auth/SocialAuthenticateTest.php
index c42ec7165..d7a9bfcff 100644
--- a/tests/TestCase/Auth/SocialAuthenticateTest.php
+++ b/tests/TestCase/Auth/SocialAuthenticateTest.php
@@ -60,7 +60,7 @@ public function setUp()
$this->SocialAuthenticate = $this->getMockBuilder('CakeDC\Users\Auth\SocialAuthenticate')
->setMethods(['_authenticate', '_getProviderName', '_mapUser', '_socialLogin', 'dispatchEvent'])
- ->disableOriginalConstructor()
+ ->setConstructorArgs([$this->Registry])
->getMock();
}
@@ -161,7 +161,7 @@ public function testGetUserSessionData()
$user = ['username' => 'username', 'email' => 'myemail@test.com'];
$this->SocialAuthenticate = $this->getMockBuilder('CakeDC\Users\Auth\SocialAuthenticate')
->setMethods(['_authenticate', '_getProviderName', '_mapUser', '_touch'])
- ->disableOriginalConstructor()
+ ->setConstructorArgs([$this->Registry])
->getMock();
$session = $this->getMock('Cake\Network\Session', ['read', 'delete']);
@@ -375,8 +375,9 @@ public function providerTwitter()
public function testSocialLogin()
{
$this->SocialAuthenticate = $this->getMockBuilder('CakeDC\Users\Auth\SocialAuthenticate')
- ->disableOriginalConstructor()
+ ->setConstructorArgs([$this->Registry])
->getMock();
+
$reflectedClass = new ReflectionClass($this->SocialAuthenticate);
$socialLogin = $reflectedClass->getMethod('_socialLogin');
$socialLogin->setAccessible(true);
@@ -398,7 +399,7 @@ public function testMapUser($data, $mappedData)
{
$data['token'] = $this->Token;
$this->SocialAuthenticate = $this->getMockBuilder('CakeDC\Users\Auth\SocialAuthenticate')
- ->disableOriginalConstructor()
+ ->setConstructorArgs([$this->Registry])
->getMock();
$reflectedClass = new ReflectionClass($this->SocialAuthenticate);
@@ -470,7 +471,7 @@ public function testMapUserException()
{
$data = [];
$this->SocialAuthenticate = $this->getMockBuilder('CakeDC\Users\Auth\SocialAuthenticate')
- ->disableOriginalConstructor()
+ ->setConstructorArgs([$this->Registry])
->getMock();
$reflectedClass = new ReflectionClass($this->SocialAuthenticate);
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index b0bbdb56c..8295913b2 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -73,6 +73,8 @@
'defaults' => 'php'
]);
+//init router
+\Cake\Routing\Router::reload();
\Cake\Core\Plugin::load('CakeDC/Users', [
'path' => dirname(dirname(__FILE__)) . DS,
From c7032c3bff8eb9470fbb275d440091776511c29c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Wed, 10 Feb 2016 10:58:50 +0000
Subject: [PATCH 0292/1397] fix docs for owner rule, fix condition in
belongsToMany
---
Docs/Documentation/OwnerRule.md | 86 +++++++++++++++++++++++
Docs/Documentation/SimpleRbacAuthorize.md | 12 +++-
src/Auth/Rules/Owner.php | 15 +++-
src/Auth/SimpleRbacAuthorize.php | 29 +++++---
tests/Fixture/PostsUsersFixture.php | 4 +-
tests/TestCase/Auth/Rules/OwnerTest.php | 6 +-
6 files changed, 134 insertions(+), 18 deletions(-)
create mode 100644 Docs/Documentation/OwnerRule.md
diff --git a/Docs/Documentation/OwnerRule.md b/Docs/Documentation/OwnerRule.md
new file mode 100644
index 000000000..db98eb455
--- /dev/null
+++ b/Docs/Documentation/OwnerRule.md
@@ -0,0 +1,86 @@
+Owner Rule
+=============
+
+Setup
+---------------
+
+SimpleRbacAuthorize will pick and use specific Rule classes (implementing the \CakeDC\Users\Auth\Rules\Rule interface).
+You only need to create your own permission rules, implement the required interface and pass the instance in the
+'allowed' param.
+
+We provide an AbstractRule you could extend too, in case you want to use rules accessing the database and using the
+default table associated to the current controller.
+
+Owner rule configuration
+-----------------
+
+The Owner rule can be configured to use the following options
+```php
+ //field in the owned table matching the user_id
+ 'ownerForeignKey' => 'user_id',
+ /*
+ * request key type to retrieve the table id, could be "params", "query", "data" to locate the table id
+ * example:
+ * yoursite.com/controller/action/XXX would be
+ * tableKeyType => 'params', 'tableIdParamsKey' => 'pass.0'
+ * yoursite.com/controlerr/action?post_id=XXX would be
+ * tableKeyType => 'query', 'tableIdParamsKey' => 'post_id'
+ * yoursite.com/controller/action [posted form with a field named post_id] would be
+ * tableKeyType => 'data', 'tableIdParamsKey' => 'post_id'
+ */
+ 'tableKeyType' => 'params',
+ // request->params key path to retrieve the owned table id
+ 'tableIdParamsKey' => 'pass.0',
+ /* define table to use or pick it from controller name defaults if null
+ * if null, table used will be based on current controller's default table
+ * if string, TableRegistry::get will be used
+ * if Table, the table object will be used
+ */
+ 'table' => null,
+ 'conditions' => [],
+```
+
+Example:
+
+(in your permissions.php file)
+```php
+[
+ 'role' => ['user'],
+ 'controller' => ['Posts'],
+ 'action' => ['edit'],
+ 'allowed' => new Owner([
+ 'ownerForeignKey' => 'owner_id',
+ ]),
+],
+```
+
+In this example, action `/posts/edit/55` will be allowed if:
+ * The user is logged in
+ * The user role is 'user'
+ * There is a post in posts table with id 55
+ * The 'owner_id' field in the post matches the user id
+
+Checking ownership in belongsToMany associations
+-----------------
+
+Let's say you have users, posts, posts_users tables, and Posts belongsToMany Users,
+you could check the ownership configuring the Owner rule:
+```php
+[
+ 'role' => ['user'],
+ 'controller' => ['Posts'],
+ 'action' => ['edit'],
+ 'allowed' => new Owner([
+ 'table' => 'PostsUsers',
+ 'id' => 'post_id',
+ 'ownerForeignKey' => 'owner_id'
+ ]),
+],
+```
+
+In this example, action `/posts/edit/55` will be allowed if:
+ * The user is logged in
+ * The user role is 'user'
+ * There is a row in posts_users table matching
+ * 'owner_id' = user id
+ * 'post_id' = 55
diff --git a/Docs/Documentation/SimpleRbacAuthorize.md b/Docs/Documentation/SimpleRbacAuthorize.md
index 3eb2a109f..17e173465 100644
--- a/Docs/Documentation/SimpleRbacAuthorize.md
+++ b/Docs/Documentation/SimpleRbacAuthorize.md
@@ -59,7 +59,7 @@ Permission rules syntax
'plugin' => 'OPTIONAL_NAME_OF_THE_PLUGIN_OR_[]_OR_*_DEFAULT_NULL',
'controller' => 'REQUIRED_NAME_OF_THE_CONTROLLER_OR_[]_OR_*'
'action' => 'REQUIRED_NAME_OF_ACTION_OR_[]_OR_*',
- 'allowed' => 'OPTIONAL_BOOLEAN_OR_CALLABLE_DEFAULT_TRUE'
+ 'allowed' => 'OPTIONAL_BOOLEAN_OR_CALLABLE_OR_INSTANCE_OF_RULE_DEFAULT_TRUE'
]
```
* If no rule allowed = true is matched for a given user role and url, default return value will be false
@@ -85,3 +85,13 @@ Example *ownership* callback, to allow users to edit their own Posts:
return false;
}
```
+
+Permission Rules
+----------------
+You could use an instance of the \CakeDC\Users\Auth\Rules\Rule interface to reuse your custom rules
+Examples:
+```php
+'allowed' => new Owner() //will pick by default the post id from the first pass param
+```
+Check the [Owner Rule](OwnerRule.md) documentation for more details
+
diff --git a/src/Auth/Rules/Owner.php b/src/Auth/Rules/Owner.php
index 0f52a1338..5be38835c 100644
--- a/src/Auth/Rules/Owner.php
+++ b/src/Auth/Rules/Owner.php
@@ -36,12 +36,19 @@ class Owner extends AbstractRule
'tableKeyType' => 'params',
// request->params key path to retrieve the owned table id
'tableIdParamsKey' => 'pass.0',
- /* define table to use or pick it from controller name defaults if null
+ /*
+ * define table to use or pick it from controller name defaults if null
* if null, table used will be based on current controller's default table
* if string, TableRegistry::get will be used
* if Table, the table object will be used
*/
'table' => null,
+ /*
+ * define the table id to be used to match the row id, this is useful when checking belongsToMany associations
+ * Example: If checking ownership in a PostsUsers table, we should use 'id' => 'post_id'
+ * If value is null, we'll use the $table->primaryKey()
+ */
+ 'id' => null,
'conditions' => [],
];
@@ -62,8 +69,12 @@ public function allowed(array $user, $role, Request $request)
} catch (Exception $ex) {
throw new OutOfBoundsException(__d('Users', 'Missing column {0} in table {1} while checking ownership permissions for user {2}', $this->config('ownerForeignKey'), $table->alias(), $userId));
}
+ $idColumn = $this->config('id');
+ if (empty($idColumn)) {
+ $idColumn = $table->primaryKey();
+ }
$conditions = array_merge([
- $table->primaryKey() => $id,
+ $idColumn => $id,
$this->config('ownerForeignKey') => $userId
], $this->config('conditions'));
diff --git a/src/Auth/SimpleRbacAuthorize.php b/src/Auth/SimpleRbacAuthorize.php
index 85c5913c2..612ccc3a7 100644
--- a/src/Auth/SimpleRbacAuthorize.php
+++ b/src/Auth/SimpleRbacAuthorize.php
@@ -11,6 +11,7 @@
namespace CakeDC\Users\Auth;
+use CakeDC\Users\Auth\Rules\Rule;
use Cake\Auth\BaseAuthorize;
use Cake\Controller\ComponentRegistry;
use Cake\Core\Configure;
@@ -19,7 +20,6 @@
use Cake\Network\Request;
use Cake\Utility\Hash;
use Cake\Utility\Inflector;
-use CakeDC\Users\Auth\Rules\Rule;
use Psr\Log\LogLevel;
/**
@@ -56,19 +56,26 @@ class SimpleRbacAuthorize extends BaseAuthorize
* - ownership
* - permissions stored in your database
* - permission based on an external service API call
- * Example ownership callback, to allow users to edit their own Posts:
+ * You could use an instance of the \CakeDC\Users\Auth\Rules\Rule interface to reuse your custom rules
+ *
+ * Examples:
+ * 1. Callback to allow users editing their own Posts:
*
* 'allowed' => function (array $user, $role, Request $request) {
- $postId = Hash::get($request->params, 'pass.0');
- $post = TableRegistry::get('Posts')->get($postId);
- $userId = Hash::get($user, 'id');
- if (!empty($post->user_id) && !empty($userId)) {
- return $post->user_id === $userId;
- }
- return false;
- }
+ * $postId = Hash::get($request->params, 'pass.0');
+ * $post = TableRegistry::get('Posts')->get($postId);
+ * $userId = Hash::get($user, 'id');
+ * if (!empty($post->user_id) && !empty($userId)) {
+ * return $post->user_id === $userId;
+ * }
+ * return false;
+ * }
+ * 2. Using the Owner Rule
+ * 'allowed' => new Owner() //will pick by default the post id from the first pass param
+ *
+ * Check the Owner Rule docs for more details
+ *
*
- * Suggestion: put your rules into a specific config file
*/
'permissions' => [],
];
diff --git a/tests/Fixture/PostsUsersFixture.php b/tests/Fixture/PostsUsersFixture.php
index 9227398ab..f4cea2af2 100644
--- a/tests/Fixture/PostsUsersFixture.php
+++ b/tests/Fixture/PostsUsersFixture.php
@@ -47,12 +47,12 @@ class PostsUsersFixture extends TestFixture
*/
public $records = [
[
- 'id' => '00000000-0000-0000-0000-000000000001',
+ 'id' => '00000000-0000-0000-0000-000000000011',
'user_id' => '00000000-0000-0000-0000-000000000001',
'post_id' => '00000000-0000-0000-0000-000000000001',
],
[
- 'id' => '00000000-0000-0000-0000-000000000002',
+ 'id' => '00000000-0000-0000-0000-000000000012',
'user_id' => '00000000-0000-0000-0000-000000000002',
'post_id' => '00000000-0000-0000-0000-000000000002',
],
diff --git a/tests/TestCase/Auth/Rules/OwnerTest.php b/tests/TestCase/Auth/Rules/OwnerTest.php
index aa320cf36..eac550ec8 100644
--- a/tests/TestCase/Auth/Rules/OwnerTest.php
+++ b/tests/TestCase/Auth/Rules/OwnerTest.php
@@ -225,7 +225,8 @@ public function testNotAllowedBecauseNoDefaultTable()
public function testAllowedBelongsToMany()
{
$this->Owner = new Owner([
- 'table' => 'PostsUsers'
+ 'table' => 'PostsUsers',
+ 'id' => 'post_id',
]);
$this->request->params = [
'plugin' => 'CakeDC/Users',
@@ -246,7 +247,8 @@ public function testAllowedBelongsToMany()
public function testNotAllowedBelongsToMany()
{
$this->Owner = new Owner([
- 'table' => 'PostsUsers'
+ 'table' => 'PostsUsers',
+ 'id' => 'post_id',
]);
$this->request->params = [
'plugin' => 'CakeDC/Users',
From f2dd1fa3f472f9c04a54c5c51e10098a3c56baa2 Mon Sep 17 00:00:00 2001
From: Yelitza Parra
Date: Thu, 11 Feb 2016 18:14:16 -0500
Subject: [PATCH 0293/1397] Fixing broken tests
---
src/Auth/SocialAuthenticate.php | 24 +++--
.../TestCase/Auth/SocialAuthenticateTest.php | 78 +++++++---------
.../Controller/Traits/LoginTraitTest.php | 24 +++--
.../Controller/Traits/SocialTraitTest.php | 90 ++++++++++++++++++-
tests/bootstrap.php | 1 -
5 files changed, 152 insertions(+), 65 deletions(-)
diff --git a/src/Auth/SocialAuthenticate.php b/src/Auth/SocialAuthenticate.php
index 2ac88c9b5..b964f43c7 100755
--- a/src/Auth/SocialAuthenticate.php
+++ b/src/Auth/SocialAuthenticate.php
@@ -122,8 +122,8 @@ protected function _normalizeConfig(&$config, $alias, $parent)
* @param mixed $value Value.
* @param string $key Key.
* @return void
- * @throws \Muffin\OAuth2\Auth\Exception\InvalidProviderException
- * @throws \Muffin\OAuth2\Auth\Exception\InvalidSettingsException
+ * @throws CakeDC\Users\Auth\Exception\InvalidProviderException
+ * @throws CakeDC\Users\Auth\Exception\InvalidSettingsException
*/
protected function _validateConfig(&$value, $key)
{
@@ -134,6 +134,16 @@ protected function _validateConfig(&$value, $key)
}
}
+ /**
+ * Get the controller associated with the collection.
+ *
+ * @return Controller instance
+ */
+ protected function _getController()
+ {
+ $this->_registry->getController();
+ }
+
/**
* Get a user based on information in the request.
*
@@ -306,10 +316,9 @@ protected function _touch(array $data)
$args = ['exception' => $exception, 'rawData' => $data];
$event = new Event(UsersAuthComponent::EVENT_FAILED_SOCIAL_LOGIN, $args);
$event = EventManager::instance()->dispatch($event);
- if (method_exists($this->_registry->getController(), 'failedSocialLogin')) {
- $this->_registry->getController()->failedSocialLogin($exception, $data, true);
+ if (method_exists($this->_getController(), 'failedSocialLogin')) {
+ $this->_getController()->failedSocialLogin($exception, $data, true);
}
-
return $event->result;
}
@@ -358,7 +367,10 @@ public function getUser(Request $request)
if (!$result = $this->_touch($user)) {
return false;
}
- $request->session()->delete(Configure::read('Users.Key.Session.social'));
+
+ if ($request->session()->check(Configure::read('Users.Key.Session.social'))) {
+ $request->session()->delete(Configure::read('Users.Key.Session.social'));
+ }
return $result;
}
diff --git a/tests/TestCase/Auth/SocialAuthenticateTest.php b/tests/TestCase/Auth/SocialAuthenticateTest.php
index d7a9bfcff..babfae221 100644
--- a/tests/TestCase/Auth/SocialAuthenticateTest.php
+++ b/tests/TestCase/Auth/SocialAuthenticateTest.php
@@ -52,16 +52,17 @@ public function setUp()
$this->controller = $this->getMock(
'Cake\Controller\Controller',
- null,
+ ['failedSocialLogin'],
[$request, $response]
);
+
$this->Request = $request;
- $this->Registry = new ComponentRegistry($this->controller);
+ $this->SocialAuthenticate = $this->_getSocialAuthenticateMockMethods(['_authenticate', '_getProviderName',
+ '_mapUser', '_socialLogin', 'dispatchEvent', '_validateConfig', '_getController']);
- $this->SocialAuthenticate = $this->getMockBuilder('CakeDC\Users\Auth\SocialAuthenticate')
- ->setMethods(['_authenticate', '_getProviderName', '_mapUser', '_socialLogin', 'dispatchEvent'])
- ->setConstructorArgs([$this->Registry])
- ->getMock();
+ $this->SocialAuthenticate->expects($this->any())
+ ->method('_getController')
+ ->will($this->returnValue($this->controller));
}
/**
@@ -73,6 +74,21 @@ public function tearDown()
unset($this->SocialAuthenticate, $this->controller);
}
+ protected function _getSocialAuthenticateMock()
+ {
+ return $this->getMockBuilder('CakeDC\Users\Auth\SocialAuthenticate')
+ ->disableOriginalConstructor()
+ ->getMock();
+ }
+
+ protected function _getSocialAuthenticateMockMethods($methods)
+ {
+ return $this->getMockBuilder('CakeDC\Users\Auth\SocialAuthenticate')
+ ->disableOriginalConstructor()
+ ->setMethods($methods)
+ ->getMock();
+ }
+
/**
* Test getUser
*
@@ -159,10 +175,8 @@ public function providerGetUser()
public function testGetUserSessionData()
{
$user = ['username' => 'username', 'email' => 'myemail@test.com'];
- $this->SocialAuthenticate = $this->getMockBuilder('CakeDC\Users\Auth\SocialAuthenticate')
- ->setMethods(['_authenticate', '_getProviderName', '_mapUser', '_touch'])
- ->setConstructorArgs([$this->Registry])
- ->getMock();
+ $this->SocialAuthenticate = $this->_getSocialAuthenticateMockMethods(['_authenticate',
+ '_getProviderName', '_mapUser', '_touch', '_validateConfig' ]);
$session = $this->getMock('Cake\Network\Session', ['read', 'delete']);
$session->expects($this->once())
@@ -210,15 +224,10 @@ public function testGetUserNotEmailProvided($rawData, $mapper)
->method('_socialLogin')
->will($this->throwException(new MissingEmailException('missing email')));
- $event = new Event('ExceptionEvent');
- $event->result = 'result';
-
- $this->SocialAuthenticate->expects($this->once())
- ->method('dispatchEvent')
- ->will($this->returnValue($event));
+ $this->controller->expects($this->once())
+ ->method('failedSocialLogin');
- $result = $this->SocialAuthenticate->getUser($this->Request);
- $this->assertEquals($result, 'result');
+ $this->SocialAuthenticate->getUser($this->Request);
}
/**
@@ -245,15 +254,7 @@ public function testGetUserNotActive($rawData, $mapper)
->method('_socialLogin')
->will($this->throwException(new UserNotActiveException('user not active')));
- $event = new Event('ExceptionEvent');
- $event->result = 'result';
-
- $this->SocialAuthenticate->expects($this->once())
- ->method('dispatchEvent')
- ->will($this->returnValue($event));
-
- $result = $this->SocialAuthenticate->getUser($this->Request);
- $this->assertEquals($result, 'result');
+ $this->SocialAuthenticate->getUser($this->Request);
}
/**
@@ -280,22 +281,13 @@ public function testGetUserNotActiveAccount($rawData, $mapper)
->method('_socialLogin')
->will($this->throwException(new AccountNotActiveException('user not active')));
- $event = new Event('ExceptionEvent');
- $event->result = 'result';
-
- $this->SocialAuthenticate->expects($this->once())
- ->method('dispatchEvent')
- ->will($this->returnValue($event));
-
- $result = $this->SocialAuthenticate->getUser($this->Request);
- $this->assertEquals($result, 'result');
+ $this->SocialAuthenticate->getUser($this->Request);
}
/**
* Test getUser
*
* @dataProvider providerTwitter
- * @expectedException CakeDC\Users\Exception\MissingEmailException
*/
public function testGetUserNotEmailProvidedTwitter($rawData, $mapper)
{
@@ -374,9 +366,7 @@ public function providerTwitter()
*/
public function testSocialLogin()
{
- $this->SocialAuthenticate = $this->getMockBuilder('CakeDC\Users\Auth\SocialAuthenticate')
- ->setConstructorArgs([$this->Registry])
- ->getMock();
+ $this->SocialAuthenticate = $this->_getSocialAuthenticateMock();
$reflectedClass = new ReflectionClass($this->SocialAuthenticate);
$socialLogin = $reflectedClass->getMethod('_socialLogin');
@@ -398,9 +388,7 @@ public function testSocialLogin()
public function testMapUser($data, $mappedData)
{
$data['token'] = $this->Token;
- $this->SocialAuthenticate = $this->getMockBuilder('CakeDC\Users\Auth\SocialAuthenticate')
- ->setConstructorArgs([$this->Registry])
- ->getMock();
+ $this->SocialAuthenticate = $this->_getSocialAuthenticateMock();
$reflectedClass = new ReflectionClass($this->SocialAuthenticate);
$mapUser = $reflectedClass->getMethod('_mapUser');
@@ -470,9 +458,7 @@ public function providerMapper()
public function testMapUserException()
{
$data = [];
- $this->SocialAuthenticate = $this->getMockBuilder('CakeDC\Users\Auth\SocialAuthenticate')
- ->setConstructorArgs([$this->Registry])
- ->getMock();
+ $this->SocialAuthenticate = $this->_getSocialAuthenticateMock();
$reflectedClass = new ReflectionClass($this->SocialAuthenticate);
$mapUser = $reflectedClass->getMethod('_mapUser');
diff --git a/tests/TestCase/Controller/Traits/LoginTraitTest.php b/tests/TestCase/Controller/Traits/LoginTraitTest.php
index a380837d1..e60b6db8d 100644
--- a/tests/TestCase/Controller/Traits/LoginTraitTest.php
+++ b/tests/TestCase/Controller/Traits/LoginTraitTest.php
@@ -40,6 +40,12 @@ public function setUp()
$this->Trait = $this->getMockBuilder('CakeDC\Users\Controller\Traits\LoginTrait')
->setMethods(['dispatchEvent', 'redirect'])
->getMockForTrait();
+
+ $this->Trait->Auth = $this->getMockBuilder('Cake\Controller\Component\AuthComponent')
+ ->setMethods(['config'])
+ ->disableOriginalConstructor()
+ ->getMock();
+
$this->Trait->request = $request;
}
@@ -64,7 +70,7 @@ public function testLoginHappy()
$this->Trait->request = $this->getMockBuilder('Cake\Network\Request')
->setMethods(['is'])
->getMock();
- $this->Trait->request->expects($this->once())
+ $this->Trait->request->expects($this->any())
->method('is')
->with('post')
->will($this->returnValue(true));
@@ -102,7 +108,7 @@ public function testAfterIdentifyEmptyUser()
$this->Trait->request = $this->getMockBuilder('Cake\Network\Request')
->setMethods(['is'])
->getMock();
- $this->Trait->request->expects($this->once())
+ $this->Trait->request->expects($this->any())
->method('is')
->with('post')
->will($this->returnValue(true));
@@ -146,12 +152,6 @@ public function testAfterIdentifyEmptyUserSocialLogin()
->disableOriginalConstructor()
->getMock();
- $this->Trait->expects($this->once())
- ->method('redirect')
- ->with([
- 'action' => 'social-email'
- ]);
-
$this->Trait->login();
}
@@ -320,6 +320,14 @@ public function testFailedSocialUserNotActive()
->method('redirect')
->with(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login']);
+ $this->Trait->Auth->expects($this->at(0))
+ ->method('config')
+ ->with('authError', 'Your user has not been validated yet. Please check your inbox for instructions');
+
+ $this->Trait->Auth->expects($this->at(1))
+ ->method('config')
+ ->with('flash.params', ['class' => 'success']);
+
$this->Trait->failedSocialLogin($event->data['exception'], $event->data['rawData'], true);
}
diff --git a/tests/TestCase/Controller/Traits/SocialTraitTest.php b/tests/TestCase/Controller/Traits/SocialTraitTest.php
index 0d0d95d49..e5e02bbf5 100644
--- a/tests/TestCase/Controller/Traits/SocialTraitTest.php
+++ b/tests/TestCase/Controller/Traits/SocialTraitTest.php
@@ -30,7 +30,7 @@ public function setUp()
true,
true,
true,
- ['_getOpauthInstance', 'redirect', '_generateOpauthCompleteUrl']
+ ['_getOpauthInstance', 'redirect', '_generateOpauthCompleteUrl', '_afterIdentifyUser', '_validateRegisterPost']
);
}
@@ -45,14 +45,18 @@ public function tearDown()
*/
public function testSocialEmail()
{
- $session = $this->getMock('Cake\Network\Session', ['check']);
- $session->expects($this->once())
+ $session = $this->getMock('Cake\Network\Session', ['check', 'delete']);
+ $session->expects($this->at(0))
->method('check')
->with('Users.social')
->will($this->returnValue('social_key'));
+ $session->expects($this->at(1))
+ ->method('delete')
+ ->with('Flash.auth');
+
$this->controller->Trait->request = $this->getMock('Cake\Network\Request', ['session']);
- $this->controller->Trait->request->expects($this->once())
+ $this->controller->Trait->request->expects($this->any())
->method('session')
->will($this->returnValue($session));
@@ -79,4 +83,82 @@ public function testSocialEmailInvalid()
$this->controller->Trait->socialEmail();
}
+
+ public function testSocialEmailPostValidateFalse()
+ {
+ $session = $this->getMock('Cake\Network\Session', ['check', 'delete']);
+ $session->expects($this->any())
+ ->method('check')
+ ->with('Users.social')
+ ->will($this->returnValue(true));
+
+ $session->expects($this->once())
+ ->method('delete')
+ ->with('Flash.auth');
+
+ $this->controller->Trait->request = $this->getMock('Cake\Network\Request', ['session', 'is']);
+ $this->controller->Trait->request->expects($this->any())
+ ->method('session')
+ ->will($this->returnValue($session));
+
+ $this->controller->Trait->request->expects($this->once())
+ ->method('is')
+ ->with('post')
+ ->will($this->returnValue(true));
+
+ $this->controller->Trait->expects($this->once())
+ ->method('_validateRegisterPost')
+ ->will($this->returnValue(false));
+
+ $this->controller->Trait->Flash = $this->getMockBuilder('Cake\Controller\Component\FlashComponent')
+ ->setMethods(['error'])
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->controller->Trait->Flash->expects($this->once())
+ ->method('error')
+ ->with('The reCaptcha could not be validated');
+
+ $this->controller->Trait->socialEmail();
+ }
+
+ public function testSocialEmailPostValidateTrue()
+ {
+ $session = $this->getMock('Cake\Network\Session', ['check', 'delete']);
+ $session->expects($this->any())
+ ->method('check')
+ ->with('Users.social')
+ ->will($this->returnValue(true));
+
+ $session->expects($this->once())
+ ->method('delete')
+ ->with('Flash.auth');
+
+ $this->controller->Trait->request = $this->getMock('Cake\Network\Request', ['session', 'is']);
+ $this->controller->Trait->request->expects($this->any())
+ ->method('session')
+ ->will($this->returnValue($session));
+
+ $this->controller->Trait->request->expects($this->once())
+ ->method('is')
+ ->with('post')
+ ->will($this->returnValue(true));
+
+ $this->controller->Trait->expects($this->once())
+ ->method('_validateRegisterPost')
+ ->will($this->returnValue(true));
+
+ $this->controller->Trait->Auth = $this->getMockBuilder('Cake\Controller\Component\AuthComponent')
+ ->setMethods(['identify'])
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->controller->Trait->Auth->expects($this->once())
+ ->method('identify');
+
+ $this->controller->Trait->expects($this->once())
+ ->method('_afterIdentifyUser');
+
+ $this->controller->Trait->socialEmail();
+ }
}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 8295913b2..5a21395a9 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -20,7 +20,6 @@
unset($findRoot);
chdir($root);
-define('DS', DIRECTORY_SEPARATOR);
define('ROOT', $root);
define('APP_DIR', 'App');
define('WEBROOT_DIR', 'webroot');
From 971203ad4a85ce657a0191c9944d8ae1f90f9a98 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?=
Date: Fri, 12 Feb 2016 10:19:59 +0000
Subject: [PATCH 0294/1397] fix missing DS
---
tests/bootstrap.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 5a21395a9..e94f7f148 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -20,6 +20,9 @@
unset($findRoot);
chdir($root);
+if (!defined('DS')) {
+ define('DS', DIRECTORY_SEPARATOR);
+}
define('ROOT', $root);
define('APP_DIR', 'App');
define('WEBROOT_DIR', 'webroot');
From 0efa39663c6ad78ed7e74cb967a4fcb57e99de43 Mon Sep 17 00:00:00 2001
From: Yelitza Parra
Date: Fri, 12 Feb 2016 10:02:05 -0500
Subject: [PATCH 0295/1397] Improving documentation
---
Docs/Documentation/Installation.md | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/Docs/Documentation/Installation.md b/Docs/Documentation/Installation.md
index 6a5cafde6..6ebe9d27a 100644
--- a/Docs/Documentation/Installation.md
+++ b/Docs/Documentation/Installation.md
@@ -56,7 +56,7 @@ Plugin::load('CakeDC/Users', ['routes' => true, 'bootstrap' => true]);
Configure::write('Users.Social.login', true); //to enable social login
```
-Then in your config/users.php
+Then in your config/users.php if you are using social login features
```
return [
'OAuth.providers.facebook.options.clientId' => 'YOUR APP ID',
@@ -67,7 +67,6 @@ return [
];
```
-
For more details, check the Configuration doc page
Load the UsersAuth Component
From 070bb60f5dc8c31fe7b7f117cb342bb6f569e6db Mon Sep 17 00:00:00 2001
From: Yelitza Parra
Date: Fri, 12 Feb 2016 12:33:52 -0500
Subject: [PATCH 0296/1397] Adding missing use
---
src/Template/Users/register.ctp | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/Template/Users/register.ctp b/src/Template/Users/register.ctp
index 773ed5fc8..f217de2f4 100644
--- a/src/Template/Users/register.ctp
+++ b/src/Template/Users/register.ctp
@@ -8,6 +8,7 @@
* @copyright Copyright 2010 - 2015, Cake Development Corporation (http://cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
+use Cake\Core\Configure;
?>
|