We're developing a business application using symfony 1.4 and in order to register, new users must read and agree to our terms of service. Currently, they are being shown the terms of service upon registration and login, but we would like to force the issue, and redirect them to the terms of service page whenever they request a page until they accept.
The only idea I've come up with so far is putting a cond开发者_StackOverflow中文版itional redirect in the global layout file, but this seems ugly and I'm not even sure that it's possible.
Suggestions?
Sounds like a job for a filter:
http://www.symfony-project.org/reference/1_4/en/12-Filters
This is pretty much wide question, but one possibility would be to check whenever they want to do anything – you must have some 'logged_in' check in place when user requests member only page [in heavy pseudocode]:
if ($!logged_in){ redirect('/login'); }
if ($!read_tos) { redirect('/tos'); } //<- this
It heavily depends on your code, where to exactly put it and how, but I would definitely put it next to this member-check.
精彩评论