Skip to content

Commit

Permalink
Merge pull request #4 from byjg/4.0
Browse files Browse the repository at this point in the history
4.0
  • Loading branch information
byjg authored Nov 24, 2018
2 parents 71c9619 + 7ebcd42 commit fd81140
Show file tree
Hide file tree
Showing 16 changed files with 127 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ install:
- composer install

script:
- phpunit --stderr
- vendor/bin/phpunit --stderr

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ $users = new ByJG\Authenticate\UsersDBDataset(

## Install

Just type: `composer require "byjg/authuser=2.0.*"`
Just type: `composer require "byjg/authuser=4.0.*"`

## Running Tests

Expand Down
50 changes: 25 additions & 25 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
{
"name": "byjg/authuser",
"description": "A simple and customizable class for enable user authentication inside your application. It is available on XML files, Relational Databases and Moodle.",
"authors": [
{
"name": "João Gilberto Magalhães",
"email": "[email protected]"
}
],
"autoload": {
"psr-4": {
"ByJG\\Authenticate\\": "src/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=5.6.0",
"byjg/micro-orm": "2.2.*",
"byjg/cache-engine": "4.0.*",
"byjg/jwt-wrapper": "1.0.*"
},
"require-dev": {
"phpunit/phpunit": "5.7.*|6.5.*"
},
"license": "MIT"
"name": "byjg/authuser",
"description": "A simple and customizable class for enable user authentication inside your application. It is available on XML files, Relational Databases and Moodle.",
"authors": [
{
"name": "João Gilberto Magalhães",
"email": "[email protected]"
}
],
"autoload": {
"psr-4": {
"ByJG\\Authenticate\\": "src/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=5.6.0",
"byjg/micro-orm": "4.0.*",
"byjg/cache-engine": "4.0.*",
"byjg/jwt-wrapper": "1.0.*"
},
"require-dev": {
"phpunit/phpunit": ">5.7"
},
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/Definition/UserDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class UserDefinition
* @param string $model
* @param string $loginField
* @param array $fieldDef
* @throws \Exception
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
*/
public function __construct(
$table = 'users',
Expand Down
6 changes: 3 additions & 3 deletions src/Interfaces/UsersInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace ByJG\Authenticate\Interfaces;

use ByJG\AnyDataset\Dataset\IteratorFilter;
use ByJG\AnyDataset\Dataset\Row;
use ByJG\AnyDataset\Core\IteratorFilter;
use ByJG\AnyDataset\Core\Row;
use ByJG\Authenticate\Definition\UserPropertiesDefinition;
use ByJG\Authenticate\Definition\UserDefinition;
use ByJG\Authenticate\Model\UserModel;
Expand Down Expand Up @@ -147,7 +147,7 @@ public function removeAllProperties($propertyName, $value = null);
* @param int $expires
* @param array $updateUserInfo
* @param array $updateTokenInfo
* @return \ByJG\AnyDataset\Dataset\Row Return the TOKEN or false if dont.
* @return \ByJG\AnyDataset\Core\Row Return the TOKEN or false if dont.
*/
public function createAuthToken(
$login,
Expand Down
50 changes: 33 additions & 17 deletions src/UsersAnyDataset.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace ByJG\Authenticate;

use ByJG\AnyDataset\Dataset\AnyDataset;
use ByJG\AnyDataset\Dataset\IteratorFilter;
use ByJG\AnyDataset\Enum\Relation;
use ByJG\AnyDataset\IteratorInterface;
use ByJG\AnyDataset\Dataset\Row;
use ByJG\AnyDataset\Core\AnyDataset;
use ByJG\AnyDataset\Core\IteratorFilter;
use ByJG\AnyDataset\Core\Enum\Relation;
use ByJG\AnyDataset\Core\IteratorInterface;
use ByJG\AnyDataset\Core\Row;
use ByJG\Authenticate\Definition\UserPropertiesDefinition;
use ByJG\Authenticate\Definition\UserDefinition;
use ByJG\Authenticate\Model\UserPropertiesModel;
Expand Down Expand Up @@ -34,6 +34,8 @@ class UsersAnyDataset extends UsersBase
* @param string $file
* @param UserDefinition $userTable
* @param UserPropertiesDefinition $propertiesTable
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
* @throws \ByJG\Util\Exception\XmlUtilException
*/
public function __construct(
$file,
Expand All @@ -58,8 +60,10 @@ public function __construct(
* Save the current UsersAnyDataset
*
* @param \ByJG\Authenticate\Model\UserModel $model
* @throws \ByJG\AnyDataset\Exception\DatabaseException
* @throws \Exception
* @throws \ByJG\AnyDataset\Core\Exception\DatabaseException
* @throws \ByJG\Authenticate\Exception\UserExistsException
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
* @throws \ByJG\Util\Exception\XmlUtilException
*/
public function save(UserModel $model)
{
Expand Down Expand Up @@ -95,7 +99,7 @@ public function save(UserModel $model)
*
* @param IteratorFilter $filter Filter to find user
* @return UserModel
* @throws \Exception
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
*/
public function getUser($filter)
{
Expand All @@ -113,7 +117,8 @@ public function getUser($filter)
*
* @param string $login
* @return boolean
* @throws \ByJG\AnyDataset\Exception\DatabaseException
* @throws \ByJG\AnyDataset\Core\Exception\DatabaseException
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
* @throws \ByJG\Util\Exception\XmlUtilException
*/
public function removeByLoginField($login)
Expand Down Expand Up @@ -149,9 +154,11 @@ public function getIterator($filter = null)
* @param string $propertyName
* @param string $value
* @return boolean
* @throws \ByJG\AnyDataset\Exception\DatabaseException
* @throws \ByJG\AnyDataset\Core\Exception\DatabaseException
* @throws \ByJG\Authenticate\Exception\UserExistsException
* @throws \ByJG\Authenticate\Exception\UserNotFoundException
* @throws \Exception
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
* @throws \ByJG\Util\Exception\XmlUtilException
*/
public function addProperty($userId, $propertyName, $value)
{
Expand All @@ -173,8 +180,10 @@ public function addProperty($userId, $propertyName, $value)
* @param string $propertyName
* @param string $value
* @return boolean
* @throws \ByJG\AnyDataset\Exception\DatabaseException
* @throws \Exception
* @throws \ByJG\AnyDataset\Core\Exception\DatabaseException
* @throws \ByJG\Authenticate\Exception\UserExistsException
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
* @throws \ByJG\Util\Exception\XmlUtilException
*/
public function removeProperty($userId, $propertyName, $value = null)
{
Expand All @@ -201,8 +210,10 @@ public function removeProperty($userId, $propertyName, $value = null)
* @param string $propertyName Property name
* @param string $value Property value with a site
* @return bool|void
* @throws \ByJG\AnyDataset\Exception\DatabaseException
* @throws \Exception
* @throws \ByJG\AnyDataset\Core\Exception\DatabaseException
* @throws \ByJG\Authenticate\Exception\UserExistsException
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
* @throws \ByJG\Util\Exception\XmlUtilException
*/
public function removeAllProperties($propertyName, $value = null)
{
Expand All @@ -215,9 +226,9 @@ public function removeAllProperties($propertyName, $value = null)
}

/**
* @param \ByJG\AnyDataset\Dataset\Row $row
* @param \ByJG\AnyDataset\Core\Row $row
* @return \ByJG\Authenticate\Model\UserModel
* @throws \Exception
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
*/
private function createUserModel(Row $row)
{
Expand All @@ -241,6 +252,11 @@ private function createUserModel(Row $row)
return $userModel;
}

/**
* @param $userid
* @return bool
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
*/
public function removeUserById($userid)
{
$iteratorFilter = new IteratorFilter();
Expand Down
27 changes: 20 additions & 7 deletions src/UsersBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace ByJG\Authenticate;

use ByJG\AnyDataset\Enum\Relation;
use ByJG\AnyDataset\Dataset\IteratorFilter;
use ByJG\AnyDataset\Core\Enum\Relation;
use ByJG\AnyDataset\Core\IteratorFilter;
use ByJG\Authenticate\Definition\UserPropertiesDefinition;
use ByJG\Authenticate\Definition\UserDefinition;
use ByJG\Authenticate\Exception\NotAuthenticatedException;
Expand Down Expand Up @@ -32,6 +32,7 @@ abstract class UsersBase implements UsersInterface

/**
* @return UserDefinition
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
*/
public function getUserDefinition()
{
Expand Down Expand Up @@ -67,6 +68,7 @@ abstract public function save(UserModel $model);
* @param string $email
* @param string $password
* @return void
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
*/
public function addUser($name, $userName, $email, $password)
{
Expand All @@ -80,9 +82,10 @@ public function addUser($name, $userName, $email, $password)
}

/**
* @param $model
* @param UserModel $model
* @return bool
* @throws \ByJG\Authenticate\Exception\UserExistsException
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
*/
public function canAddUser($model)
{
Expand Down Expand Up @@ -113,7 +116,8 @@ abstract public function getUser($filter);
*
* @param string $email
* @return UserModel
* */
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
*/
public function getByEmail($email)
{
$filter = new IteratorFilter();
Expand All @@ -127,6 +131,7 @@ public function getByEmail($email)
*
* @param $username
* @return UserModel
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
*/
public function getByUsername($username)
{
Expand All @@ -141,7 +146,8 @@ public function getByUsername($username)
*
* @param string $login
* @return UserModel
* */
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
*/
public function getByLoginField($login)
{
$filter = new IteratorFilter();
Expand All @@ -156,7 +162,8 @@ public function getByLoginField($login)
*
* @param string $userid
* @return UserModel
* */
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
*/
public function getById($userid)
{
$filter = new IteratorFilter();
Expand All @@ -179,7 +186,8 @@ abstract public function removeByLoginField($login);
* @param string $userName User login
* @param string $password Plain text password
* @return UserModel
* */
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
*/
public function isValidUser($userName, $password)
{
$filter = new IteratorFilter();
Expand All @@ -202,6 +210,7 @@ public function isValidUser($userName, $password)
* @param string $value Property value
* @return bool
* @throws \ByJG\Authenticate\Exception\UserNotFoundException
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
*/
public function hasProperty($userId, $propertyName, $value = null)
{
Expand All @@ -228,6 +237,7 @@ public function hasProperty($userId, $propertyName, $value = null)
* @param string $propertyName Property name
* @return array
* @throws \ByJG\Authenticate\Exception\UserNotFoundException
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
*/
public function getProperty($userId, $propertyName)
{
Expand Down Expand Up @@ -279,6 +289,7 @@ abstract public function removeAllProperties($propertyName, $value = null);
* @param int|string $userId
* @return bool
* @throws \ByJG\Authenticate\Exception\UserNotFoundException
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
*/
public function isAdmin($userId)
{
Expand All @@ -305,6 +316,7 @@ public function isAdmin($userId)
* @param array $updateTokenInfo
* @return string the TOKEN or false if dont.
* @throws \ByJG\Authenticate\Exception\UserNotFoundException
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
*/
public function createAuthToken(
$login,
Expand Down Expand Up @@ -354,6 +366,7 @@ public function createAuthToken(
* @return array
* @throws \ByJG\Authenticate\Exception\NotAuthenticatedException
* @throws \ByJG\Authenticate\Exception\UserNotFoundException
* @throws \ByJG\Serializer\Exception\InvalidArgumentException
*/
public function isValidToken($login, $uri, $secret, $token)
{
Expand Down
Loading

0 comments on commit fd81140

Please sign in to comment.