Skip to content

Commit

Permalink
Merge pull request #170 from armanist/master
Browse files Browse the repository at this point in the history
Dropbox related refactoring and minor text changes
  • Loading branch information
armanist authored Nov 1, 2024
2 parents 1e5b026 + 07141f3 commit c801623
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @OA\Info(
* title="Quantum API documentation",
* version="2.9.0",
* description=" *Quantum Documentation: https://quantum.softberg.org/en/docs/v1/overview"
* description=" *Quantum Documentation: https://quantumphp.io/en/docs/v1/overview"
* ),
* @OA\SecurityScheme(
* securityScheme="bearer_token",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* @OA\Info(
* title="Quantum API documentation",
* version="2.9.0",
* description=" *Quantum Documentation: https://quantum.softberg.org/en/docs/v1/overview"
* description=" *Quantum Documentation: https://quantumphp.io/en/docs/v1/overview"
* ),
* @OA\SecurityScheme(
* securityScheme="bearer_token",
Expand Down
4 changes: 2 additions & 2 deletions src/Libraries/Module/Templates/Demo/Web/Views/auth/signup.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
</div>
<div class="row">
<div class="input-field col s12">
<label class="auth-form-label"><?php _t(\'common.first_name\'); ?></label>
<label class="auth-form-label"><?php _t(\'common.firstname\'); ?></label>
<input type="text" name="firstname" value="<?php echo old(\'firstname\') ?>" />
</div>
</div>
<div class="row">
<div class="input-field col s12">
<label class="auth-form-label"><?php _t(\'common.last_name\'); ?></label>
<label class="auth-form-label"><?php _t(\'common.lastname\'); ?></label>
<input type="text" name="lastname" value="<?php echo old(\'lastname\') ?>" />
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</div>
<div class=\"index-links\">
<a href=\"<?php echo base_url(true) . '/' . current_lang() ?>/about\" class=\"white-text\"><?php _t('common.about') ?></a>
<a href=\"https://quantum.softberg.org\" target=\"_blank\" class=\"white-text\"><?php _t('common.learn_more') ?></a>
<a href=\"https://quantumphp.io\" target=\"_blank\" class=\"white-text\"><?php _t('common.learn_more') ?></a>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<?php echo partial(\'partials/messages/error\') ?>
<?php endif; ?>
<?php echo partial(\'post/partials/modal\', [\'item\' => t(\'common.the_image\')]) ?>
<?php echo partial(\'post/partials/modal\', [\'item\' => t(\'common.image\')]) ?>
<div class="card teal accent-4">
<div class="card-content">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<h4 class="center-align grey-text"><?php _t(\'common.no_posts\') ?>... <?php _t(\'common.try_creating\') ?></h4>
<?php endif; ?>
<?php echo partial(\'post/partials/modal\', [\'item\' => t(\'common.the_post\')]) ?>
<?php echo partial(\'post/partials/modal\', [\'item\' => t(\'common.post\')]) ?>
<?php if (auth()->check()): ?>
<div class="fixed-action-btn">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
<?php echo $pagination->getPagination(0, 5) ?>
</div>
<?php endif; ?>
<?php echo partial(\'post/partials/modal\', [\'item\' => t(\'common.the_post\')]) ?>
<?php echo partial(\'post/partials/modal\', [\'item\' => t(\'common.post\')]) ?>
</div>';
57 changes: 29 additions & 28 deletions src/Libraries/Storage/Adapters/Dropbox/DropboxApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,32 @@ public function fetchTokens(string $code, string $redirectUrl): ?object
return $response;
}

/**
* Fetches the access token by refresh token
* @param string $refreshToken
* @return string
* @throws AppException
* @throws HttpException
* @throws LangException
*/
private function fetchAccessTokenByRefreshToken(string $refreshToken): string
{
$params = [
'refresh_token' => $refreshToken,
'grant_type' => 'refresh_token',
'client_id' => $this->appKey,
'client_secret' => $this->appSecret
];

$tokenUrl = self::AUTH_TOKEN_URL . '?' . http_build_query($params, '', '&');

$response = $this->sendRequest($tokenUrl);

$this->tokenService->saveTokens($response->access_token);

return $response->access_token;
}

/**
* Sends rpc request
* @param string $endpoint
Expand Down Expand Up @@ -224,17 +250,17 @@ public function path(string $name): array
* @param string $uri
* @param mixed|null $data
* @param array $headers
* @param string $method
* @return mixed|null
* @throws AppException
* @throws HttpException
* @throws LangException
* @throws Exception
*/
public function sendRequest(string $uri, $data = null, array $headers = [])
public function sendRequest(string $uri, $data = null, array $headers = [], string $method = 'POST')
{
$this->httpClient
->createRequest($uri)
->setMethod('POST')
->setMethod($method)
->setData($data)
->setHeaders($headers)
->start();
Expand All @@ -253,7 +279,6 @@ public function sendRequest(string $uri, $data = null, array $headers = [])
$refreshToken = $this->tokenService->getRefreshToken();

$accessToken = $this->fetchAccessTokenByRefreshToken($refreshToken);
$this->tokenService->saveTokens($accessToken);

$prevHeaders['Authorization'] = 'Bearer ' . $accessToken;

Expand All @@ -267,30 +292,6 @@ public function sendRequest(string $uri, $data = null, array $headers = [])
return $responseBody;
}

/**
* Fetches the access token by refresh token
* @param string $refreshToken
* @return string
* @throws AppException
* @throws HttpException
* @throws LangException
*/
private function fetchAccessTokenByRefreshToken(string $refreshToken): string
{
$params = [
'refresh_token' => $refreshToken,
'grant_type' => 'refresh_token',
'client_id' => $this->appKey,
'client_secret' => $this->appSecret
];

$tokenUrl = self::AUTH_TOKEN_URL . '?' . http_build_query($params, '', '&');

$response = $this->sendRequest($tokenUrl);

return $response->access_token;
}

/**
* Checks if the access token need refresh
* @param int $code
Expand Down

0 comments on commit c801623

Please sign in to comment.