Skip to content

Commit

Permalink
Merge branch 'feature/fix-tests'
Browse files Browse the repository at this point in the history
  • Loading branch information
steinkel committed Feb 6, 2016
2 parents 574dbe2 + 7e593c9 commit dbe0823
Show file tree
Hide file tree
Showing 39 changed files with 198 additions and 150 deletions.
4 changes: 3 additions & 1 deletion Docs/Documentation/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down Expand Up @@ -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'],
Expand Down
9 changes: 8 additions & 1 deletion Docs/Documentation/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Composer
------

```
composer require cakedc/users:3.1.*
composer require cakedc/users
```

if you want to use social login features...
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Docs/Documentation/SocialAuthenticate.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Configure::write('Users', [
],
'Social' => [
//enable social login
'login' => true,
'login' => false,
],
'Key' => [
'Session' => [
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
"type": "cakephp-plugin",
"require": {
"php": ">=5.4.16",
"cakephp/cakephp": "~3.1"
"cakephp/cakephp": "~3.1",
"muffin/oauth2": "dev-master",
"league/oauth1-client": "@stable"
},
"require-dev": {
"phpunit/phpunit": "*",
"muffin/oauth2": "dev-master"
"cakephp/cakephp-codesniffer": "^2.0"
},
"suggest": {
"league/oauth2-facebook": "Provide Social Authentication with Facebook",
Expand Down
2 changes: 1 addition & 1 deletion config/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
],
'Social' => [
//enable social login
'login' => true,
'login' => false,
],
'Profile' => [
//Allow view other users profiles
Expand Down
2 changes: 1 addition & 1 deletion src/Auth/SimpleRbacAuthorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
22 changes: 16 additions & 6 deletions src/Auth/Social/Mapper/AbstractMapper.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
<?php
/**
* Created by PhpStorm.
* User: ajibarra
* Date: 10/16/15
* Time: 7:02 AM
* Copyright 2010 - 2015, Cake Development Corporation (http://cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2010 - 2015, Cake Development Corporation (http://cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

namespace CakeDC\Users\Auth\Social\Mapper;

use Cake\Utility\Hash;

/**
* AbstractMapper
*
*/
abstract class AbstractMapper
{
/**
Expand Down Expand Up @@ -46,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)
{
Expand All @@ -59,6 +66,8 @@ public function __construct($rawData, $mapFields = null)
}
/**
* Invoke method
*
* @return mixed
*/
public function __invoke()
{
Expand All @@ -67,6 +76,7 @@ public function __invoke()

/**
* If email is present the user is validated
*
* @return bool
*/
protected function _validated()
Expand Down
13 changes: 13 additions & 0 deletions src/Auth/Social/Mapper/Facebook.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
<?php
/**
* Copyright 2010 - 2015, Cake Development Corporation (http://cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2010 - 2015, Cake Development Corporation (http://cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

namespace CakeDC\Users\Auth\Social\Mapper;

use Cake\Utility\Hash;

/**
* Facebook Mapper
*
*/
class Facebook extends AbstractMapper
{

Expand Down
15 changes: 11 additions & 4 deletions src/Auth/Social/Mapper/Google.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
<?php
/**
* Created by PhpStorm.
* User: ajibarra
* Date: 10/16/15
* Time: 7:02 AM
* Copyright 2010 - 2015, Cake Development Corporation (http://cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2010 - 2015, Cake Development Corporation (http://cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

namespace CakeDC\Users\Auth\Social\Mapper;

/**
* Google Mapper
*
*/
class Google extends AbstractMapper
{
/**
Expand Down
15 changes: 11 additions & 4 deletions src/Auth/Social/Mapper/Instagram.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
<?php
/**
* Created by PhpStorm.
* User: ajibarra
* Date: 10/16/15
* Time: 7:02 AM
* Copyright 2010 - 2015, Cake Development Corporation (http://cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2010 - 2015, Cake Development Corporation (http://cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

namespace CakeDC\Users\Auth\Social\Mapper;

use Cake\Utility\Hash;

/**
* Instagram Mapper
*
*/
class Instagram extends AbstractMapper
{
/**
Expand Down
13 changes: 8 additions & 5 deletions src/Auth/Social/Mapper/LinkedIn.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php
/**
* Created by PhpStorm.
* User: ajibarra
* Date: 10/16/15
* Time: 7:02 AM
* Copyright 2010 - 2015, Cake Development Corporation (http://cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2010 - 2015, Cake Development Corporation (http://cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

namespace CakeDC\Users\Auth\Social\Mapper;
Expand All @@ -22,4 +25,4 @@ class LinkedIn extends AbstractMapper
'bio' => 'headline',
'link' => 'publicProfileUrl'
];
}
}
18 changes: 12 additions & 6 deletions src/Auth/Social/Mapper/Twitter.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
<?php
/**
* Created by PhpStorm.
* User: ajibarra
* Date: 10/16/15
* Time: 7:02 AM
* Copyright 2010 - 2015, Cake Development Corporation (http://cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2010 - 2015, Cake Development Corporation (http://cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

namespace CakeDC\Users\Auth\Social\Mapper;


use Cake\Utility\Hash;

/**
* Twitter Mapper
*
*/
class Twitter extends AbstractMapper
{

Expand Down Expand Up @@ -42,4 +48,4 @@ protected function _link()
{
return self::TWITTER_BASE_URL . Hash::get($this->_rawData, $this->_mapFields['username']);
}
}
}
21 changes: 15 additions & 6 deletions src/Auth/Social/Util/SocialUtils.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
<?php
/**
* Copyright 2010 - 2015, Cake Development Corporation (http://cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2010 - 2015, Cake Development Corporation (http://cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

namespace CakeDC\Users\Auth\Social\Util;

use League\OAuth2\Client\Provider\AbstractProvider;
use ReflectionClass;

/**
* Created by PhpStorm.
* User: ajibarra
* Date: 10/17/15
* Time: 3:45 PM
* Social Utils
*
*/
class SocialUtils
{
/**
* Get provider from classname
* @param AbstractProvider $provider
*
* @param AbstractProvider $provider provider
* @return string
*/
public static function getProvider(AbstractProvider $provider)
{
$reflect = new ReflectionClass($provider);
return $reflect->getShortName();
}
}
}
Loading

0 comments on commit dbe0823

Please sign in to comment.