Skip to content

Commit

Permalink
fix: remove extra remote call (#205)
Browse files Browse the repository at this point in the history
* fix: remove double call

* feat: editModel added in server properties

* fix!: treat enabled as a boolean in the editor

* feat: remove private method
  • Loading branch information
64knl authored Mar 15, 2024
1 parent 0c2290d commit ad76d24
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/Http/Controllers/InfoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public function settings()
$settings->background = (object) [
'url' => env('APP_LOGIN_IMAGE_URL', '/siteboss/images/back.jpg'),
'credits' => (object) [
'name' => env('APP_LOGIN_IMAGE_SOURCE_NAME', 'Dr. Matthias Ripp'),
'url' => env('APP_LOGIN_IMAGE_SOURCE_URL', 'https://www.flickr.com/photos/56218409@N03/14605956625'),
'name' => env('APP_LOGIN_IMAGE_SOURCE_NAME', 'zeitfaenger.at'),
'url' => env('APP_LOGIN_IMAGE_SOURCE_URL', 'https://flickr.com/photos/kwarz/'),
'license' => env('APP_LOGIN_IMAGE_SOURCE_LICENSE', 'CC BY 2.0'),
],
];
Expand Down
14 changes: 12 additions & 2 deletions src/Services/Assets/Components/ComponentText.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public function validate($newValue): bool
*/
protected function customProperties(): object
{
// BUG: TODO: editModel should just be a property,
// not a server property
$customProperties = [];
if (isset($this->properties()->type) && $this->properties()->type == 'richtext') {
if (isset($this->properties()->editorSettings) && trim($this->properties()->editorSettings) !== '') {
$setting = EditorSetting::where('name', $this->properties()->editorSettings)->first();
Expand All @@ -67,11 +70,18 @@ protected function customProperties(): object
}

if (isset($setting->settings)) {
return (object) ['editorSettings' => json_decode($setting->settings)];
$customProperties['editorSettings'] = json_decode($setting->settings);
}
}
if (
$this->assetItem->properties->type == 'richtext' &&
isset( $this->assetItem->server_properties->editModal) &&
$this->assetItem->server_properties->editModal === true
) {
$customProperties['editModal'] = true;
}

return (object) [];
return (object) $customProperties;
}

public function asyncPostRequest()
Expand Down
30 changes: 14 additions & 16 deletions src/Services/Auth/RemoteTokenDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

class RemoteTokenDecoder extends AbstractTokenDecoder
{
private \stdClass $decodedToken;
private ?object $decodedToken = null;

protected function decodeToken(): void
{
$this->decodedToken = $this->getDecodedToken();
$this->getDecodedToken();
}

protected function verifyToken(): void
Expand All @@ -38,21 +38,19 @@ protected function verifyToken(): void

public function getDecodedToken(): \stdClass
{
return $this->getRemoteAuthenticatedToken();
}

private function getRemoteAuthenticatedToken(): \stdClass
{
$userEndpoint = $this->openIdConfiguration['userinfo_endpoint'];
if (! $userEndpoint) {
throw OpenIDException::noUserInfoEndpoint();
}

$response = Http::withToken($this->token)->get($userEndpoint);
if (! $response->ok()) {
throw new \Exception('Token is invalid.');
if ($this->decodedToken === null) {
$userEndpoint = $this->openIdConfiguration['userinfo_endpoint'];
if (! $userEndpoint) {
throw OpenIDException::noUserInfoEndpoint();
}

$response = Http::withToken($this->token)->get($userEndpoint);
if (! $response->ok()) {
throw new \Exception('Token is invalid.');
}
$this->decodedToken = (object) $response->json();
}

return (object) $response->json();
return $this->decodedToken;
}
}
4 changes: 3 additions & 1 deletion src/Services/Editor/Fields/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public function serverProperties(): void
$options[] = (object) ['value' => $table->name, 'label' => $table->name];
}
$this->addDropDown('editorSettings', 'Editor settings (for rich text editor)', $options);

// BUG: TODO: editModel should just be a property,
// not a server property
$this->addCheckbox('editModal', 'Edit texts in popup (required for ContentBlock/Childtable)');
$this->addTitle('Validation');

$this->addDropDown('regExTemplate', 'Built in validations', [
Expand Down

0 comments on commit ad76d24

Please sign in to comment.