Skip to content

Commit

Permalink
Merge pull request #110 from JaberWiki/main
Browse files Browse the repository at this point in the history
import VerifyCsrfToken and refactor
  • Loading branch information
mpociot committed Aug 3, 2023
2 parents cee8899 + aff2080 commit bd03a50
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
7 changes: 4 additions & 3 deletions routes/api.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?php

use Illuminate\Support\Facades\Route;
use Native\Laravel\Http\Controllers\CreateSecurityCookieController;
use Native\Laravel\Http\Controllers\DispatchEventFromAppController;
use App\Http\Middleware\VerifyCsrfToken;
use Native\Laravel\Http\Controllers\NativeAppBootedController;
use Native\Laravel\Http\Middleware\PreventRegularBrowserAccess;
use Native\Laravel\Http\Controllers\CreateSecurityCookieController;
use Native\Laravel\Http\Controllers\DispatchEventFromAppController;

Route::group(['middleware' => PreventRegularBrowserAccess::class], function () {
Route::post('_native/api/booted', NativeAppBootedController::class);
Route::post('_native/api/events', DispatchEventFromAppController::class);
})->withoutMiddleware(\App\Http\Middleware\VerifyCsrfToken::class);
})->withoutMiddleware(VerifyCsrfToken::class);

Route::get('_native/api/cookie', CreateSecurityCookieController::class);
22 changes: 10 additions & 12 deletions src/Dialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,23 @@ public function asSheet(string $windowId = null): self
return $this;
}

public function open()
public function dataArray(): array
{
$result = $this->client->post('dialog/open', [
return [
'title' => $this->title,
'windowReference' => $this->windowReference,
'defaultPath' => $this->defaultPath,
'filters' => $this->filters,
'buttonLabel' => $this->buttonLabel,
'properties' => array_unique($this->properties),
])->json('result');
];
}

public function open()
{
$result = $this->client->post('dialog/open', $this->dataArray())->json('result');

if (! in_array('multiSelections', $this->properties)) {
if (!in_array('multiSelections', $this->properties)) {
return $result[0] ?? null;
}

Expand All @@ -141,13 +146,6 @@ public function open()

public function save()
{
return $this->client->post('dialog/save', [
'title' => $this->title,
'windowReference' => $this->windowReference,
'defaultPath' => $this->defaultPath,
'filters' => $this->filters,
'buttonLabel' => $this->buttonLabel,
'properties' => array_unique($this->properties),
])->json('result');
return $this->client->post('dialog/save', $this->dataArray())->json('result');
}
}

0 comments on commit bd03a50

Please sign in to comment.