I’d like to e-mail all my users a link to a symfony site that I am writing, and have it so that when they follow that link they are logged in to the site (probably with a special role, like IS_AUTHENTICATED_REMEMBERED), and redirected to a certain page. How can I do this?
So the link would be something like:
http://example.com/?key=[some sort secret key with their account encoded in it]
Inspired by this message and this code, I wrote a controller that gets the user from the database, verifies the secret key, then fakes a login token as follows:
(you need this at the top of your file)
It seems to work, and the user has a role of
AUTO_LOGINso I can easily restrict them from accessing more sensitive stuff until they have logged in with a username and password as normal.