Skip to content
This repository has been archived by the owner on Jul 8, 2022. It is now read-only.

Warn or prevent users from unpublishing/deleting Virtual Y Login/Dashboard pages #134

Open
froboy opened this issue Apr 23, 2021 · 0 comments

Comments

@froboy
Copy link
Collaborator

froboy commented Apr 23, 2021

If a privileged user removes either the Virtual Y Login page or Virtual Y homepage they might accidentally break the site. We should warn users or prevent these actions.

YUSA discussed this and we decided to completely block users from deleting these pages, but not do anything else, mostly for simplicity sake. It may be more desirable to present an interstitial Are you sure you want to do this page if either of these actions is taken.

Our code, for adapting:

/**
 * Implements hook_node_access().
 */
function our_module_node_access(NodeInterface $node, $op, AccountInterface $account) {
  $config = \Drupal::config('openy_gated_content.settings')->getRawData();
  $url = \Drupal::service('path_alias.manager')->getAliasByPath('/node/'. $node->id());
  switch ($op) {
    case 'delete':
      if($url == $config['virtual_y_url'] || $url == $config['virtual_y_login_url']
        || $url == $config['virtual_y_logout_url']) {
        return AccessResult::forbidden();
      } else {
        return AccessResult::neutral();
      }
  }
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants