add anonymous users support - #22
Conversation
Hello @bpolaszek, do you have any suggestion to fix those failing checks with --prefer-stable option? |
bpolaszek
commented
Jul 31, 2020
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. |
htaoufikallah
commented
Aug 1, 2020
No worries @bpolaszek I'll wait, thank you |
bpolaszek
commented
Aug 15, 2020
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'])) {
thrownewMethodNotAllowedHttpException(['POST', 'DELETE']);
}
$data = json_decode($request->getContent(), true);
$subscription = $data['subscription'] ?? [];
$options = $data['options'] ?? [];
$user = $user ?? newAnonymousUser($options); // options being an arbitrary array of data sent by the clientThis 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? |
htaoufikallah
commented
Aug 16, 2020
Hello @bpolaszek, |
bobemoe
commented
Aug 6, 2023
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? |
bpolaszek
left a comment
There was a problem hiding this comment.
Sorry for the delay!
Would you mind implementing default methods of AnonymousUser, i.e. getRoles should return an empty array, etc.
Thanks!
Ben
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
htaoufikallah
commented
Sep 20, 2023
please recheck and let me know if anything need to be done. |
bpolaszek
commented
Jul 15, 2024
Approved too fast: missing this in publicfunctiongetUserIdentifier(): string
{
return'';
}This method has been introduced in SF6's |
No description provided.