Re: [SPAM] Implementing User login expiration

2013-07-04 Thread Dave Koo
Great solution Sam! On Tuesday, April 9, 2013 11:30:41 AM UTC-7, Sam Solomon wrote: > > Depending on if the expiration is a temporary thing or if you actually > want to permanently deactivate the user, this may be even simpler and > database efficient (and is what we use to ban users): > > class

Re: [SPAM] Implementing User login expiration

2013-04-09 Thread Sam Solomon
Depending on if the expiration is a temporary thing or if you actually want to permanently deactivate the user, this may be even simpler and database efficient (and is what we use to ban users): class DeactivateUserMiddleware(object): def process_request(self, request): if request.us

Re: [SPAM] Implementing User login expiration

2013-04-08 Thread John DeRosa
On Apr 5, 2013, at 5:33 PM, Nikolas Stevenson-Molnar wrote: > How about creating request middleware to sign out deactivated users? > Something like: > > if request.user.profile.expired: >logout(request) > > If you're concerned about the extra database hit per request, then maybe > cache th

Re: Implementing User login expiration

2013-04-08 Thread Tom Evans
On Sat, Apr 6, 2013 at 12:24 AM, John DeRosa wrote: > I have a Profile table that's 1:1 with the User table. Each Profile row has > an account_expiration field. > > I want to invalidate users when their accounts expire. By "invalidate", I > mean: They can't log in, and they can't use the system an

Re: Implementing User login expiration

2013-04-05 Thread Nikolas Stevenson-Molnar
How about creating request middleware to sign out deactivated users? Something like: if request.user.profile.expired: logout(request) If you're concerned about the extra database hit per request, then maybe cache the expiration? expire_date = cache.get("%d_expire" % request.user.id) if not e

Implementing User login expiration

2013-04-05 Thread John DeRosa
I have a Profile table that's 1:1 with the User table. Each Profile row has an account_expiration field. I want to invalidate users when their accounts expire. By "invalidate", I mean: They can't log in, and they can't use the system any more. The closer I look, the more complicated it seems.