Verified Commit 876ba8e6 authored by Mehdi Baaboura's avatar Mehdi Baaboura
Browse files

Added debug messages to Gigadrive login flow

parent 754a693a
<?php
/**
/*
* Copyright (C) 2018-2020 Gigadrive - All rights reserved.
* https://gigadrivegroup.com
* https://qpostapp.com
......@@ -47,7 +47,7 @@ class CacheHandler {
public static function Manager(): FilesystemAdapter {
static $cache = null;
if (is_null($cache)) {
$cache = new FilesystemAdapter("app.cache", 0, sys_get_temp_dir() . "/mcsh-cache");
$cache = new FilesystemAdapter("app.cache", 0, sys_get_temp_dir() . "/qpost-" . $_ENV["APP_ENV"] . "-cache");
}
return $cache;
}
......
......@@ -73,7 +73,7 @@ class RegisterController extends qpostController {
*/
$gigadriveRepository = $entityManager->getRepository(UserGigadriveData::class);
$token = $gigadriveRepository->getGigadriveTokenFromCode($code);
$token = $gigadriveRepository->getGigadriveTokenFromCode($code, $this->generalService->logger);
if (!is_null($token)) {
$userData = $gigadriveRepository->getGigadriveUserData($token);
......
<?php
/**
/*
* Copyright (C) 2018-2020 Gigadrive - All rights reserved.
* https://gigadrivegroup.com
* https://qpostapp.com
......@@ -23,6 +23,7 @@ namespace qpost\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Gigadrive\Bundle\SymfonyExtensionsBundle\DependencyInjection\Util;
use Psr\Log\LoggerInterface;
use qpost\Cache\CacheHandler;
use qpost\Entity\UserGigadriveData;
use qpost\Factory\HttpClientFactory;
......@@ -42,9 +43,10 @@ class UserGigadriveDataRepository extends ServiceEntityRepository {
/**
* @param string $code
* @param LoggerInterface|null $logger
* @return string|null
*/
public function getGigadriveTokenFromCode(string $code): ?string {
public function getGigadriveTokenFromCode(string $code, ?LoggerInterface $logger = null): ?string {
if (Util::isEmpty($code)) return null;
$cacheName = "gigadriveToken_" . $code;
......@@ -72,6 +74,10 @@ class UserGigadriveDataRepository extends ServiceEntityRepository {
if (isset($j["success"]) && !empty($j["success"]) && isset($j["token"])) {
$token = $j["token"];
CacheHandler::setToCache($cacheName, $token, 3 * 60);
} else {
if ($logger) {
$logger->error("Failed to fetch Gigadrive code", ["data" => $j, "content" => $content, "body" => $body]);
}
}
}
}
......
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