Skip to content

Commit

Permalink
Api: Throw 404 if page not found
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Schendel committed May 31, 2022
1 parent af929e4 commit 4fe92ed
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ We now have created a basic Twack-component and you now the general concepts how

## Changelog

### Changes in 2.2.5(2022-06-01)

- Api: Throw 404 if page not found

### Changes in 2.2.4 (2022-04-29)

- Api: Added support for Multi-Language URLS
Expand Down
2 changes: 1 addition & 1 deletion Twack.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function getModuleInfo() {
return [
'title' => 'Twack',
'author' => 'Sebastian Schendel',
'version' => '2.2.4',
'version' => '2.2.5',
'summary' => 'Reusable components for your ProcessWire-templates.',
'singular' => true,
'autoload' => true,
Expand Down
8 changes: 6 additions & 2 deletions TwackApiAccess.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,16 @@ protected static function pageRequest(Page $page, $languageFromPath) {
}
}

if (!$page->viewable(wire('user')->language)) {
if (!($page instanceof Page) || !$page->id) {
throw new NotFoundException();
} elseif (!$page->viewable(wire('user')->language)) {
throw new ForbiddenException();
}
}

if (!$page->viewable()) {
if (!($page instanceof Page) || !$page->id) {
throw new NotFoundException();
} elseif (!$page->viewable()) {
throw new ForbiddenException();
}

Expand Down

0 comments on commit 4fe92ed

Please sign in to comment.