Skip to content

Commit

Permalink
Merge pull request #23 from boite/symfony-5
Browse files Browse the repository at this point in the history
Compatible with Symfony 5
  • Loading branch information
joostfaassen committed Feb 23, 2020
2 parents 4124c9f + 9e6f9b6 commit 143a34b
Show file tree
Hide file tree
Showing 17 changed files with 252 additions and 128 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,3 +1,5 @@
/.php_cs
/.php_cs.cache
vendor/*
.env
composer.lock
Expand Down
25 changes: 25 additions & 0 deletions .php_cs.dist
@@ -0,0 +1,25 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
;

return PhpCsFixer\Config::create()
->setRules([
'@PSR1' => true,
'@PSR2' => true,
'@Symfony' => true,
'single_line_throw' => false,
'no_superfluous_phpdoc_tags' => false,
'ordered_imports' => true,
'phpdoc_align' => false,
'no_extra_consecutive_blank_lines' => false,
'blank_line_before_statement' => [
'statements' => [
'declare',
]
],
'array_syntax' => false,
])
->setFinder($finder)
;
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -52,9 +52,10 @@ Please refer to the `examples/` directory for other examples.

A Silex Provider is available [here](https://github.com/linkorb/silex-provider-userbase-client)

### Symfony 4
### Symfony

A Symfony 4 bundle can be found [here](https://github.com/linkorb/userbase-client-bundle)
A Symfony bundle can be found [here](https://github.com/linkorb/userbase-client-bundle).
It works with Symfony 4 and 5 projects.

## License

Expand Down
10 changes: 10 additions & 0 deletions UPGRADE-2.0.md
@@ -0,0 +1,10 @@
UPGRADE FROM 1.9 to 2.0
=======================

- The User class no longer implements Symfony's `AdvancedUserInterface` which
it has been removed from Symfony 5. Use of the methods of this interface
should be replaced by performing User and Account checks in UserCheckers.

A temporary replacement for the removed interface is
`UserBase\Client\Model\LegacyAdvancedUserInterface`, but use this only as a
last resort and as a temporary fix.
10 changes: 5 additions & 5 deletions composer.json
Expand Up @@ -18,14 +18,14 @@
],
"require": {
"php": ">=5.3.0",
"linkorb/userbase-role-contracts": "^1.0",
"symfony/security": "~2.6 || ~3.0 || ^4.0|| ^5.0",
"linkorb/envoi": "^1.1",
"linkorb/userbase-role-contracts": "^2.0",
"psr/cache": "~1.0",
"symfony/cache": "~3.0|| ^4.0 || ^5.0 ",
"linkorb/envoi": "^1.1"
"symfony/cache": "~3.0 || ^4.0 || ^5.0",
"symfony/security-core": "~2.6 || ~3.0 || ^4.0 || ^5.0"
},
"require-dev": {
"symfony/dotenv": "~3.0 || ^4.0"
"symfony/dotenv": "~3.0 || ^4.0 || ^5.0"
},
"autoload": {
"psr-4": {
Expand Down
18 changes: 9 additions & 9 deletions src/Client.php
Expand Up @@ -2,14 +2,16 @@

namespace UserBase\Client;

use UserBase\Client\Model\User;
use Psr\Cache\CacheItemPoolInterface;
use RuntimeException;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder;
use UserBase\Client\Model\Account;
use UserBase\Client\Model\AccountUser;
use UserBase\Client\Model\AccountEmail;
use UserBase\Client\Model\AccountProperty;
use UserBase\Client\Model\AccountUser;
use UserBase\Client\Model\Policy;
use Psr\Cache\CacheItemPoolInterface;
use RuntimeException;
use UserBase\Client\Model\User;

if (!function_exists('curl_file_create')) {
function curl_file_create($filename, $mimetype = '', $postname = '')
Expand Down Expand Up @@ -52,7 +54,7 @@ public function __construct($url, $username = null, $password = null, $partition
}

$this->partition = $partition;
$this->cache = new \Symfony\Component\Cache\Adapter\ArrayAdapter();
$this->cache = new ArrayAdapter();
}

private function parse_dsn(array $parts)
Expand Down Expand Up @@ -285,8 +287,7 @@ public function getData($uri, $jsonData = null)

$json = curl_exec($ch);

if($json === false)
{
if (false === $json) {
throw new RuntimeException('Curl error: '.curl_error($ch));
}

Expand All @@ -296,7 +297,6 @@ public function getData($uri, $jsonData = null)
$this->timeDataCollector->stopMeasure('getData');
}


if (200 != $code) {
throw new RuntimeException('HTTP Status code: '.$code.'message: '.$json);
}
Expand All @@ -313,7 +313,7 @@ public function checkCredentials($username, $password)
} catch (\Exception $e) {
return false;
}
$encoder = new \Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder();
$encoder = new MessageDigestPasswordEncoder();
$valid = $encoder->isPasswordValid($user->getPassword(), $password, $user->getSalt());

return $valid;
Expand Down

0 comments on commit 143a34b

Please sign in to comment.