Commit 309e6b34 authored by hlarget's avatar hlarget 👹
Browse files

Merge branch 'release/2.0.5'

parents fa639d77 13ec535a
......@@ -35,7 +35,20 @@ class CompanyController extends AbstractController
$client = $konnectClient->getGuzzleClient();
$companyId = $this->getUser()->getCompanyId();
$response = $client->get("/api/company/$companyId/reset_secret");
$response = $client->get("api/company/$companyId/reset_secret");
return new Response($response->getBody()->getContents(), Response::HTTP_OK, ['Content-Type' => 'application/json']);
}
/**
* Get current user company from antar
* @Route("/company")
* @param KonnectClient $konnectClient
* @return Response
*/
public function getCompanyFromAntar(KonnectClient $konnectClient) {
$companyUid = $this->getUser()->getCompanyId();
$client = $konnectClient->getGuzzleClient();
$response = $client->get("api/company/$companyUid");
return new Response($response->getBody()->getContents(), Response::HTTP_OK, ['Content-Type' => 'application/json']);
}
}
\ No newline at end of file
......@@ -25,7 +25,7 @@ class ServiceController extends AbstractController
public function getServicesListForMenu(KonnectClient $konnectClient)
{
$client = $konnectClient->getGuzzleClient();
$response = $client->get("/api/services/menu");
$response = $client->get("api/services/menu");
return new Response($response->getBody()->getContents(), Response::HTTP_OK, ['Content-Type' => 'application/json']);
}
}
\ No newline at end of file
......@@ -46,7 +46,7 @@ class UserController extends AbstractController
{
$client = $konnectClient->getGuzzleClient();
$userId = $this->getUser()->getId();
$response = $client->get("/api/user/$userId/services");
$response = $client->get("api/user/$userId/services");
return new Response($response->getBody()->getContents(), Response::HTTP_OK, ['Content-Type' => 'application/json']);
}
......
......@@ -63,8 +63,15 @@ class KonnectClient
{
$config = $this->getConfiguration()['authentication'];
return new Client([
"base_uri" => $config['url'],
"base_uri" => $this->addTrailerSlashIfNotExists($config['url']),
"auth" => [$config['token'], $config['secret']]
]);
}
private function addTrailerSlashIfNotExists($url) {
return substr($url, -1) === "/" ?
$url :
"$url/";
}
}
\ No newline at end of file
......@@ -50,7 +50,7 @@ class UserProvider implements UserProviderInterface, OAuthAwareUserProviderInter
$user = new User($auth0ParsedObject[self::AUTH0_USER_DATA_KEY_ID]);
$user->setEmail($auth0ParsedObject[self::AUTH0_USER_DATA_KEY_EMAIL]);
$user->setUsername($auth0ParsedObject[self::AUTH0_USER_DATA_KEY_NICKNAME]);
$user->setGivenName($auth0ParsedObject[self::AUTH0_USER_METADATA_KEY][self::AUTH0_USER_METADATA_KEY_GIVEN_NAME] ?? $auth0ParsedObject[self::AUTH0_USER_DATA_KEY_NICKNAME]);
$user->setGivenName($auth0ParsedObject[self::AUTH0_USER_METADATA_KEY_GIVEN_NAME] ?? $auth0ParsedObject[self::AUTH0_USER_DATA_KEY_NICKNAME]);
$user->setPicture($auth0ParsedObject[self::AUTH0_USER_DATA_KEY_PICTURE]);
$user->setCompanyId($auth0ParsedObject[self::AUTH0_USER_APP_METADATA_KEY][self::AUTH0_USER_APP_METADATA_KEY_COMPANYID]);
$user->setSubscriptions($auth0ParsedObject[self::AUTH0_USER_APP_METADATA_KEY][self::AUTH0_USER_APP_METADATA_KEY_SUBSCRIPTIONS]);
......
......@@ -3,9 +3,9 @@ Konnect Bundle
This project aims to mutualize the code used by konnect and its modules.
Konnect Bundle have two main goals:
- Give a way to project to authenticate to Auth0
- All the common Auth0 files are stored here to avoid duplicate in all project
- Allow Modules to call Konnect API to get informations about user or about service.
- Give the project a way to authenticate using Auth0
- All the common Auth0 files are stored here to avoid duplicating them in all project
- Allow Requests to Konnect API and get informations about user and service.
Take a look at [the Konnect Bundle API documentation](https://doc.agoods.fr/v2/api/konnectBundle.html)
Konnect Bundle import some classes in your module:
......@@ -37,7 +37,7 @@ in `/config/bundles.php`
##Configuration
If you need to make call to the API of Konnect you need to configure Konnect-bundle
If you need to make request to the API of Konnect you need to configure Konnect-bundle
In your `konnect.yml`:
```yaml
......@@ -110,9 +110,6 @@ You can find [a detailed documentation here](https://gitlab.agoods.fr/documentat
- Set a route on a Controller
> If you add a new controller, you need to declare this controller in `Resources/config/services.yml` with the same syntax that existent controllers
> *NOTE*: don't use autowiring on Konnect Bundle, use `$api = $this->get("konnect.api");` for example where `konnect.api` is the alias for KonnectApi set in `services.yml`
- Add a function in the `Services/KonnectApi.php` that calls a route on Konnect. You need to pass a config array with token/secret to authenticate the service on Konnect. See existent functions to know how to do that.
##### You need to add a file to use it on modules ?
- Put your files on a folder
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment