Skip to content

Commit 9feedad

Browse files
committed
issue #11. rename config to REDIRECT_TO_LOGIN_IMMEDIATELY
1 parent 968e991 commit 9feedad

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ AUTO_LOGOUT = {'IDLE_TIME': timedelta(minutes=10)}
5454
```
5555

5656
The user will log out the next time the page is requested.
57-
See `REDIRECT_TO_LOGIN_PAGE` to log out right after the idle-time has expired
57+
See `REDIRECT_TO_LOGIN_IMMEDIATELY` to log out right after the idle-time has expired
5858
(and redirect to login page).
5959

60-
### 🔄 `REDIRECT_TO_LOGIN_PAGE` right after the idle-time has expired
60+
### 🔄 `REDIRECT_TO_LOGIN_IMMEDIATELY` right after the idle-time has expired
6161

62-
Use the `REDIRECT_TO_LOGIN_PAGE` option
62+
Use the `REDIRECT_TO_LOGIN_IMMEDIATELY` option
6363
if you want to redirect the user to the login page
6464
immediately after the idle-time expires:
6565

@@ -68,7 +68,7 @@ from datetime import timedelta
6868

6969
AUTO_LOGOUT = {
7070
'IDLE_TIME': timedelta(minutes=10),
71-
'REDIRECT_TO_LOGIN_PAGE': True,
71+
'REDIRECT_TO_LOGIN_IMMEDIATELY': True,
7272
}
7373
```
7474

@@ -98,7 +98,7 @@ TEMPLATES = [
9898
And add it to your templates (will add a redirect script to your html):
9999

100100
```
101-
{{ redirect_to_login_page }}
101+
{{ redirect_to_login_immediately }}
102102
```
103103

104104
If you want to use this in your JavaScript code, following template variables will be useful:
@@ -108,7 +108,7 @@ var sessionEnd = {{ seconds_until_session_end }};
108108
var idleEnd = {{ seconds_until_idle_end }};
109109
```
110110

111-
`REDIRECT_TO_LOGIN_PAGE` works with `SESSION_TIME` too.
111+
`REDIRECT_TO_LOGIN_IMMEDIATELY` works with `SESSION_TIME` too.
112112

113113
## ⌛ Limit session time
114114

@@ -132,7 +132,7 @@ AUTO_LOGOUT = {'SESSION_TIME': timedelta(hours=1)}
132132

133133
**NOTE**
134134

135-
See `REDIRECT_TO_LOGIN_PAGE` option
135+
See `REDIRECT_TO_LOGIN_IMMEDIATELY` option
136136
if you want to redirect user to the login page
137137
right after the idle-time has expired.
138138

@@ -183,6 +183,6 @@ AUTO_LOGOUT = {
183183
'IDLE_TIME': timedelta(minutes=5),
184184
'SESSION_TIME': timedelta(minutes=30),
185185
'MESSAGE': 'The session has expired. Please login again to continue.',
186-
'REDIRECT_TO_LOGIN_PAGE': True,
186+
'REDIRECT_TO_LOGIN_IMMEDIATELY': True,
187187
}
188188
```

django_auto_logout/context_processors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def auto_logout_client(request):
5050
if 'IDLE_TIME' in options:
5151
ctx['seconds_until_idle_end'] = seconds_until_idle_time_end(request, options['IDLE_TIME'], current_time)
5252

53-
if options.get('REDIRECT_TO_LOGIN_PAGE'):
53+
if options.get('REDIRECT_TO_LOGIN_IMMEDIATELY'):
5454
at = None
5555

5656
if 'SESSION_TIME' in options and 'IDLE_TIME' in options:
@@ -64,6 +64,6 @@ def auto_logout_client(request):
6464
at = f"at=Date.now()+Math.max({ ctx['seconds_until_idle_end'] },0)*1000+999;"
6565

6666
if at:
67-
ctx['redirect_to_login_page'] = mark_safe(_trim(LOGOUT_TIMEOUT_SCRIPT_PATTERN % at))
67+
ctx['redirect_to_login_immediately'] = mark_safe(_trim(LOGOUT_TIMEOUT_SCRIPT_PATTERN % at))
6868

6969
return ctx

example/example/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,5 +168,5 @@
168168
'IDLE_TIME': 10, # 10 seconds
169169
'SESSION_TIME': 120, # 2 minutes
170170
'MESSAGE': 'The session has expired. Please login again to continue.',
171-
'REDIRECT_TO_LOGIN_PAGE': True,
171+
'REDIRECT_TO_LOGIN_IMMEDIATELY': True,
172172
}

example/some_app_login_required/templates/layout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818

1919
{% block content %}{% endblock %}
2020

21-
{{ redirect_to_login_page }}
21+
{{ redirect_to_login_immediately }}
2222
</body>
2323
</html>

example/some_app_login_required/tests.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def test_script_anon(self):
212212
settings.AUTO_LOGOUT = {
213213
'IDLE_TIME': 10, # 10 seconds
214214
'SESSION_TIME': 120, # 2 minutes
215-
'REDIRECT_TO_LOGIN_PAGE': True,
215+
'REDIRECT_TO_LOGIN_IMMEDIATELY': True,
216216
}
217217
resp = self.client.get(settings.LOGIN_URL)
218218
self.assertNotContains(resp, '<script>')
@@ -227,35 +227,35 @@ def test_session_idle_combinations(self):
227227
settings.AUTO_LOGOUT = {
228228
'IDLE_TIME': 10, # 10 seconds
229229
'SESSION_TIME': 120, # 2 minutes
230-
'REDIRECT_TO_LOGIN_PAGE': True,
230+
'REDIRECT_TO_LOGIN_IMMEDIATELY': True,
231231
}
232232
self.assertContains(self.client.get(self.url), '<script>')
233233
self.assertContains(self.client.get(self.url), 'Math.min')
234234

235235
settings.AUTO_LOGOUT = {
236236
'IDLE_TIME': 10, # 10 seconds
237-
'REDIRECT_TO_LOGIN_PAGE': True,
237+
'REDIRECT_TO_LOGIN_IMMEDIATELY': True,
238238
}
239239
self.assertContains(self.client.get(self.url), '<script>')
240240
self.assertNotContains(self.client.get(self.url), 'Math.min')
241241

242242
settings.AUTO_LOGOUT = {
243243
'SESSION_TIME': 120, # 2 minutes
244-
'REDIRECT_TO_LOGIN_PAGE': True,
244+
'REDIRECT_TO_LOGIN_IMMEDIATELY': True,
245245
}
246246
self.assertContains(self.client.get(self.url), '<script>')
247247
self.assertNotContains(self.client.get(self.url), 'Math.min')
248248

249249
settings.AUTO_LOGOUT = {
250-
'REDIRECT_TO_LOGIN_PAGE': True,
250+
'REDIRECT_TO_LOGIN_IMMEDIATELY': True,
251251
}
252252
self.assertNotContains(self.client.get(self.url), '<script>')
253253

254254
def test_no_config(self):
255255
self.client.force_login(self.user)
256256

257257
settings.AUTO_LOGOUT = {
258-
'REDIRECT_TO_LOGIN_PAGE': False,
258+
'REDIRECT_TO_LOGIN_IMMEDIATELY': False,
259259
}
260260
self.assertNotContains(self.client.get(self.url), '<script>')
261261

0 commit comments

Comments
 (0)