I would like to force a user to complete some additional information once they have created and account and have validated their email address. For now, this additional information is simple (first name, last name). Once a user logs in, I am going to redirect them to an additional information page to complete this information. I'm just won开发者_如何学Godering what the best way is to ensure that this information is completed. The only thing I can think of is to store some type of flag in the session, but I would have to look at it for every single get of a view right? I can't think of any other way to do this, since I would need to check every page get, but maybe a base controller or something would be best? I'm really looking for best practices here. Thanks in advance.
The best thing would be to have a flag on your user object, and in the database. You should check every page get, and if the information has not been filled out, redirect them to that page.
However, in the best interests of your users, you may not want to force them to fill out this information.
IMO the best sites are the one's that make you want to complete your profile yourself, you can do this in a number of ways that are not so "in your face", for example allow people to do very basic things immeditely with just a very limited profile and on the main page have a nice largish "Profile 40% complete" with a link (or whatever perc of course), and...make any advanced function require them to fill out the profile.
Make it their choice, but give an incentive. (just the % complete is enough for some people ;-) people don't like to feel incomplete)
I guess the best practice would be to add a role like "Profile_Completed".
This would let you lock down select portions of the site in the usual way without having to code anything up.
精彩评论