Use jsonapi to post a flagging needs permission 'administer flaggings' and always failed to "A flagging can't be moved to another entity."

Created on 1 November 2019, about 6 years ago
Updated 2 March 2024, almost 2 years ago

Problem/Motivation

At present, flaggings cannot be posted or retrieved from jsonapi unless the user has the "Administer flaggings" permission.

This is incorrect behavior because users may have permission to make flaggings/access their own flags, so they shouldn't be automatically denied access.

According to Wim Leers โ†’ , the Flag module needs to provide a normalizer for rest/jsonapi.

Steps to reproduce

1. Create a flag and have authenticated users flag some content.
2. Use jsonapi to try to post a flagging while logged in as a non-admin user that has permission to post a flag.

You will get an "access denied" message.

Proposed resolution

Add support for POST operations for flags in jsonapi.

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ› Bug report
Status

Needs review

Version

4.0

Component

Flag core

Created by

๐Ÿ‡จ๐Ÿ‡ณChina lawxen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update almost 2 years ago
    Waiting for branch to pass
  • ๐Ÿ‡ธ๐Ÿ‡ชSweden kevinn

    Created patch from the fork.

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States kurttrowbridge

    I've been using MR 15, but it's no longer applying to the newest dev version of the module. It looks like there are conflicts in src/Entity/Flagging.php and src/FlagService.php. Will report back if I'm able to get it taken care of myself.

  • ๐Ÿ‡น๐Ÿ‡ทTurkey makbay

    As a work around, maybe you can implement hook_ENTITY_TYPE_access()</a> in a custom module:

    /**
     * Implements hook_ENTITY_TYPE_access().
     */
    function YOURMODULE_flagging_access(EntityInterface $entity, $operation, AccountInterface $account) {
      if ($entity->getFlagId() === 'your_flag_id' && $operation === 'view') {
          ... maybe some other logic ...
          return AccessResult::allowed();
      }
      return AccessResult::neutral();
    }
    
  • ๐Ÿ‡ฆ๐Ÿ‡นAustria daniel.pernold

    daniel.pernold โ†’ made their first commit to this issueโ€™s fork.

  • Pipeline finished with Failed
    11 months ago
    #446509
  • Pipeline finished with Failed
    11 months ago
    Total: 216s
    #446515
  • Pipeline finished with Failed
    11 months ago
    Total: 170s
    #446523
  • Pipeline finished with Failed
    11 months ago
    Total: 176s
    #446525
  • Pipeline finished with Failed
    11 months ago
    Total: 223s
    #446539
  • Pipeline finished with Failed
    25 days ago
    #703120
  • Pipeline finished with Failed
    25 days ago
    Total: 205s
    #703125
  • Pipeline finished with Failed
    25 days ago
    Total: 302s
    #703129
  • Pipeline finished with Failed
    25 days ago
    #703137
  • Pipeline finished with Failed
    24 days ago
    Total: 240s
    #703840
  • Pipeline finished with Failed
    24 days ago
    Total: 213s
    #703942
  • Pipeline finished with Failed
    24 days ago
    Total: 219s
    #704120
  • Pipeline finished with Failed
    23 days ago
    Total: 54417s
    #704261
  • Pipeline finished with Running
    23 days ago
    #704940
  • Pipeline finished with Failed
    23 days ago
    Total: 856s
    #705110
  • Pipeline finished with Failed
    23 days ago
    #705176
  • Pipeline finished with Failed
    23 days ago
    Total: 209s
    #705190
  • Pipeline finished with Success
    23 days ago
    Total: 235s
    #705361
  • Pipeline finished with Success
    23 days ago
    Total: 250s
    #705444
  • Pipeline finished with Success
    19 days ago
    Total: 223s
    #709429
Production build 0.71.5 2024