-
Notifications
You must be signed in to change notification settings - Fork 42
add anonymous users support #22
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Hello @bpolaszek, do you have any suggestion to fix those failing checks with --prefer-stable option? |
Hello @htaoufikallah - thank you for this PR! I'm currently pretty busy and I can't review this at the very moment, but that's definitely something I wanted to work on. I'll try to check that out within the next days/weeks, please be patient. |
No worries @bpolaszek I'll wait, thank you |
Hello @htaoufikallah, thanks for your patience and for the time you took to improve this library! 🙂 Allowing anonymous users is something that I wanted to do for a while, in order to send notifications to people that did not necessarily sign up to the app. They could be targeted through different, arbitrary attributes than the associated user id (main controller expecting an optional, additional payload of data associated to the subscription). The main concern that prevented me from doing it, is that it would break existing implementations, because interfaces have to be changed to allow nullable What I notice from your implementation are:
Those issues are legit, however I think we can address them in a different way.
if (!in_array($request->getMethod(), ['POST', 'DELETE'])) {
throw new MethodNotAllowedHttpException(['POST', 'DELETE']);
}
$data = json_decode($request->getContent(), true);
$subscription = $data['subscription'] ?? [];
$options = $data['options'] ?? [];
$user = $user ?? new AnonymousUser($options); // options being an arbitrary array of data sent by the client This way, the main controller always provide a valid
Regarding anonymous -> logged-in upgrade:
Unless there's something I didn't spot out, this would help bringing this feature without breaking existing apps. What do you think? |
Hello @bpolaszek, |
This looks like just what I need. What is stopping it being merged? Happy to help here, I am setting up a new project where I would need this so could test this at the same time? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay!
Would you mind implementing default methods of AnonymousUser
, i.e. getRoles
should return an empty array, etc.
Thanks!
Ben
please recheck and let me know if anything need to be done. |
Approved too fast: missing this in public function getUserIdentifier(): string
{
return '';
} This method has been introduced in SF6's |
No description provided.