mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-12 14:40:09 +01:00
Make viewing pastes work again
This commit is contained in:
parent
f59182093c
commit
ee097929c0
2 changed files with 3 additions and 7 deletions
|
@ -16,22 +16,18 @@ class AbilityHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function can(string $action, mixed $subject) : bool {
|
public function can(string $action, mixed $subject) : bool {
|
||||||
if ($this->user === null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$is_destructive = in_array($action, self::DESTRUCTIVE_ACTIONS);
|
$is_destructive = in_array($action, self::DESTRUCTIVE_ACTIONS);
|
||||||
|
|
||||||
if (is_a($subject, 'Paste')) {
|
if (is_a($subject, 'Paste')) {
|
||||||
if (($subject->visible == Paste::VISIBILITY_PRIVATE) || $is_destructive) {
|
if (($subject->visible == Paste::VISIBILITY_PRIVATE) || $is_destructive) {
|
||||||
return $subject->user_id === $this->user->id;
|
return $this->user !== null && $subject->user_id === $this->user->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_a($subject, 'User')) {
|
if (is_a($subject, 'User')) {
|
||||||
return !$is_destructive || $subject->id === $this->user->id;
|
return !$is_destructive || ($this->user !== null && $subject->id === $this->user->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<div class="bd-lead">
|
<div class="bd-lead">
|
||||||
<?php if (isset($error)): ?>
|
<?php if (isset($error)): ?>
|
||||||
<p class="help is-danger subtitle is-6"><?= pp_html_escape($error) ?></p>
|
<p class="help is-danger subtitle is-6"><?= pp_html_escape($error) ?></p>
|
||||||
<?php if ($password_required): ?>
|
<?php if (isset($password_required) && $password_required): ?>
|
||||||
<h1 class="title is-5">This paste is password-protected.</h1>
|
<h1 class="title is-5">This paste is password-protected.</h1>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="field has-addons">
|
<div class="field has-addons">
|
||||||
|
|
Loading…
Add table
Reference in a new issue