Skip to content

Commit 1176d70

Browse files
committed
Disable push subscribing functionality from guests
Signed-off-by: Matt Friedman <maf675@gmail.com> fix Signed-off-by: Matt Friedman <maf675@gmail.com> Is you is or is you ain’t Signed-off-by: Matt Friedman <maf675@gmail.com>
1 parent 6571c83 commit 1176d70

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

notification/method/webpush.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ public function get_ucp_template_data(helper $controller_helper, form_helper $fo
379379
}
380380

381381
return [
382-
'NOTIFICATIONS_WEBPUSH_ENABLE' => $this->config['wpn_webpush_dropdown_subscribe'] || stripos($this->user->page['page'], 'notification_options'),
382+
'NOTIFICATIONS_WEBPUSH_ENABLE' => $this->allowed_user() && ($this->config['wpn_webpush_dropdown_subscribe'] || stripos($this->user->page['page'], 'notification_options')),
383383
'U_WEBPUSH_SUBSCRIBE' => $controller_helper->route('phpbb_webpushnotifications_ucp_push_subscribe_controller'),
384384
'U_WEBPUSH_UNSUBSCRIBE' => $controller_helper->route('phpbb_webpushnotifications_ucp_push_unsubscribe_controller'),
385385
'VAPID_PUBLIC_KEY' => $this->config['wpn_webpush_vapid_public'],
@@ -553,4 +553,17 @@ protected function load_recipients_data(): array
553553

554554
return $notify_users;
555555
}
556+
557+
/**
558+
* User is allowed to use web push notifications
559+
*
560+
* @return bool
561+
*/
562+
protected function allowed_user()
563+
{
564+
return $this->user->id() !== ANONYMOUS
565+
&& !$this->user->data['is_bot']
566+
&& (int) $this->user->data['user_type'] !== USER_IGNORE
567+
&& (int) $this->user->data['user_type'] !== USER_INACTIVE;
568+
}
556569
}

0 commit comments

Comments
 (0)