Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Security] Add ability for voters to explain their vote#20690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
javiereguiluz merged 1 commit intosymfony:7.3fromMrYamous:20658
May 23, 2025

Conversation

MrYamous
Copy link
Contributor

Copy link
Member

@javiereguiluzjaviereguiluz left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Matthieu, this is a good start, but I think we should also display an example of using this feature to add an explanation in some of the voter examples.

If you return ``true`` from ``supports()``, then this method is called. Your
job is to return ``true`` to allow access and ``false`` to deny access.
The ``$token`` can be used to find the current user object (if any). In this
example, all of the complex business logic is included to determine access.
The ``$token`` can be used to find the current user object (if any). The ``$vote``
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

perhaps document were this can be seen? or retrieved to be displayed?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I am not sure to understand your point here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I meant something like the workflow transition blocker message
is it possible to see this "vote message" somewhere and how ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I agree with@94noni. Having a short section explaining how to retrieve and display the reasons to users would be a great addition. It would help developers make better use of the new Vote object in real-world applications.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I did some tweaks while merging, but we can do further tweaks in future PRs if we think this needs to be improved. Thanks.


if (!$user instanceof User) {
// the user must be logged in; if not, deny access
$vote->reasons[] = 'The user is not logged in.';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think we should instead use theaddReason() method.

$vote?->addReason('The user is not logged in.');

{
$user = $token->getUser();
$vote ??= new Vote();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

should be removed while accounting for@javiereguiluz's comment:

Suggested change
$vote ??= new Vote();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Fixed while merging. Thanks.

return true;
}

$vote->reasons[] = 'You are not the owner of the Post.';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

$vote is undefined in this example, I guess a few more changes are needed to pass $vote

javiereguiluz reacted with thumbs up emoji

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Fixed while merging. Thanks.

Copy link
Member

@nicolas-grekasnicolas-grekasMay 23, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

not really, the private method has no $vote argument ;)

@javiereguiluzjaviereguiluz merged commit523229b intosymfony:7.3May 23, 2025
3 checks passed
@javiereguiluz
Copy link
Member

Thanks Matthieu!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@javiereguiluzjaviereguiluzjaviereguiluz requested changes

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@OskarStarkOskarStarkOskarStark left review comments

@SpomkySpomkySpomky left review comments

@94noni94noni94noni left review comments

Assignees
No one assigned
Projects
None yet
Milestone
7.3
Development

Successfully merging this pull request may close these issues.

[Security] Add ability for voters to explain their vote
7 participants
@MrYamous@javiereguiluz@nicolas-grekas@OskarStark@Spomky@94noni@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp