msgphp / symfony-demo-app

A Symfony demo application with basic user management
https://github.com/msgphp/msgphp
MIT License
0 stars 0 forks source link

Feature Request: Invitations #111

Closed tacman closed 5 years ago

tacman commented 5 years ago

FOSUserBundle supports invitations, any chance user-bundle could add similar support, or at least documentation on how to do so?

https://symfony.com/doc/current/bundles/FOSUserBundle/adding_invitation_registration.html

I'm migrating a subscription application, and am using this opportunity to purge inactive users. My idea is to send existing subscribers an invitation, requiring them to re-register, and allow social media registration/login at that point. I've been following the demo app, but if there's a way to leverage existing code or ideas on the registration invitation, I'd prefer to use that.

ro0NL commented 5 years ago

Hi @tacman i think i solved a similar use case in the demo app with "one-time-login tokens".

See https://github.com/msgphp/symfony-demo-app/pull/62 for the initial changeset

Conceptually you cannot register a new user by invitation code, and at the same time store the code with a user. In that case the user is already considered registered.

So alternatively you could create a list of invitation codes, and couple it with the created user after registration. But maybe you're just looking for one-time-login tokens :D

ro0NL commented 5 years ago

From the example at https://symfony.com/doc/current/bundles/FOSUserBundle/adding_invitation_registration.html , im not sure how it works ... Where is the user created from an invitation? Or does it assume the users already exist beforehand :thinking: (maybe FOS does it somewhere?)

tacman commented 5 years ago

Invitations contain the one-time login token, along with an optional blob of pre-defined data (e..g ROLE_ADMIN, or their name/organization if that is known when the invitation is created).

When the invitation is sent, there's a link with ?ic=, which goes to the registration page. Quite possible to use all of that logic and simply redirect the link to the user-bundle login page, as you've done.

I'm working on a demo app/tutorial that is based on your demo app but adds some real-world content. I'll try to get invitations working, then we can figure out if it makes sense to include that in your bundle's core.

On Mon, Jul 8, 2019 at 10:50 AM Roland Franssen notifications@github.com wrote:

From the example at https://symfony.com/doc/current/bundles/FOSUserBundle/adding_invitation_registration.html , im not sure how it works? Where is the user created from an invition? Or does it assumes the users already exists beforehand 🤔 (maybe FOS does it somewhere?)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/msgphp/msgphp/issues/336?email_source=notifications&email_token=AAEXIQPGIZ2LI5ZITJIJ5ZDP6NHZXA5CNFSM4H632L7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZNKP2A#issuecomment-509257704, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEXIQMTA32RGMAU47BCKR3P6NHZXANCNFSM4H632L7A .

ro0NL commented 5 years ago

Maybe we can enhance the demo as such :) i tend to keep pure business logic (opinionated) out of core bundles.

Hence the demo defines it's own one-time-login console command, entities etc. All linked to the "core" User domain.

I think we're dealing with 2 distinct concepts;