From f51d5c72ef0cb0eee8bcc2f6ed431277a2a85ac0 Mon Sep 17 00:00:00 2001 From: a-sansara Date: Thu, 16 Mar 2017 01:58:14 +0100 Subject: [PATCH] update README --- README.md | 74 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 59 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 82c17b2..269bba5 100644 --- a/README.md +++ b/README.md @@ -23,20 +23,23 @@ Or add the package to your `composer.json`. ``` "require": { - "meta-tech/pws-server" : "~1.0" + "meta-tech/pws-server" : "^1.0" } ``` -## Usage +### Usage -managing controllers & routing in application -cf [ MetaTech\Silex\Provider\ControllerServiceProvider ](https://github.com/meta-tech/silex-controller-service) +see [ MetaTech\Silex\Provider\ControllerServiceProvider ](https://github.com/meta-tech/silex-controller-service) +to managing controllers & routing in application ```php namespace MetaTech\PwsServer; use MetaTech\Silex\Application as App; use MetaTech\Silex\Provider\ControllerServiceProvider as CtrlProvider; +use MetaTech\Silex\Provider\UserProvider; +use MetaTech\Db\PdoWrapper; +use MetaTech\Db\Profile; use MetaTech\PwsAuth\Authenticator; use MetaTech\PwsServer\Ctrl\Test; use MetaTech\PwsServer\Ctrl\WebService; @@ -54,6 +57,12 @@ class Application extends App $app['ws.authenticator'] = function ($app) { return new Authenticator($app['config']['pwsauth']); }; + $app['pdo'] = function ($app) { + return new PdoWrapper(new Profile($app['config']['db']['default'])); + }; + $app['user.provider'] = function ($app) { + return new UserProvider($app['pdo']); + }; } /*! @@ -72,11 +81,9 @@ class Application extends App Controller example : ```php -userProvider = $userProvider; + } + + public function checkUser($login, $password, $key, PasswordEncoderInterface $passEncoder = null) + { + $done = false; + try { + if (!is_null($passEncoder)) { + $user = $this->userProvider->loadUserByUsername($login); + $salt = $this->authenticator->getUserSalt($login); + $done = $user->key == $key && $passEncoder->encodePassword($password, $salt) == $user->getPassword(); + } + } + catch(\Exception $e) { + //~ var_dump($e->getTraceAsString()); + } + return $done; + } +} +``` ### Test uris : @@ -119,11 +168,6 @@ access through pws-client : * servername/ws/isauth -### @todo - -subclassing `MetaTech\Silex\Ws\Authentication` to give checkUser db implementation example - - ### License The project is released under the MIT license, see the LICENSE file.