-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from digao21/master
corrigindo o bug da sessao
- Loading branch information
Showing
3 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from datetime import datetime, timedelta | ||
from django.conf import settings | ||
from django.contrib import auth | ||
from django.http import HttpResponsePermanentRedirect | ||
|
||
|
||
class AutoLogout: | ||
def process_request(self, request): | ||
if not request.user.is_authenticated() : | ||
#Can't log out if not logged in | ||
return | ||
|
||
try: | ||
if datetime.now() - request.session['last_touch'] > timedelta( 0, settings.AUTO_LOGOUT_DELAY * 60, 0): | ||
del request.session['last_touch'] | ||
auth.logout(request) | ||
request.session['advise'] = 'true'; | ||
#return HttpResponsePermanentRedirect(redirect_url) | ||
except KeyError: | ||
pass | ||
|
||
request.session['last_touch'] = datetime.now() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters