Skip to content

Commit

Permalink
⚡ [#1485] Fixed session bind syntax and redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
jiromaykin committed Oct 23, 2023
1 parent 7f8de14 commit 8d795dc
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/open_inwoner/accounts/tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ def test_logout(self):
"""Test that a user is able to log out and page redirects to root endpoint."""
# Log out user and redirection
logout_response = self.app.get(reverse("logout"), user=self.user)
self.assertRedirects(logout_response, reverse("pages-root"))
self.assertRedirects(logout_response, reverse("login"))
self.assertFalse(logout_response.follow().context["user"].is_authenticated)


Expand Down
4 changes: 2 additions & 2 deletions src/open_inwoner/accounts/tests/test_profile_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ def test_delete_regular_user_success(self):
# check redirect
self.assertRedirects(
self.app.get(response.url),
reverse("pages-root"),
reverse("login"),
status_code=302,
target_status_code=200,
fetch_redirect_response=True,
Expand All @@ -548,7 +548,7 @@ def test_delete_user_with_digid_login_success(self):
# check redirect
self.assertRedirects(
self.app.get(response.url),
reverse("pages-root"),
reverse("login"),
status_code=302,
target_status_code=200,
fetch_redirect_response=True,
Expand Down
4 changes: 2 additions & 2 deletions src/open_inwoner/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,10 @@
"ADMIN_SESSION_COOKIE_AGE", 3600
) # Default 1 hour max session duration for admins
SESSION_WARN_DELTA = 60 # Warn 1 minute before end of session.
SESSION_COOKIE_AGE = 900 # Set to 15 minutes
SESSION_COOKIE_AGE = 900 # Set to 15 minutes or less for testing

LOGIN_REDIRECT_URL = "/"
LOGOUT_REDIRECT_URL = "/"
LOGOUT_REDIRECT_URL = "/accounts/login/"

#
# SECURITY settings
Expand Down
6 changes: 0 additions & 6 deletions src/open_inwoner/js/components/modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,8 @@ export default class Modal {
}

setListeners() {
this.node.addEventListener('click', (event) => {
event.preventDefault()
this.hide()
})

this.close.addEventListener('click', (event) => {
event.preventDefault()

this.hide()
})

Expand Down
9 changes: 5 additions & 4 deletions src/open_inwoner/js/components/session/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ class SessionTimeout {
this.warnTime * 1000
)
this.expiredTimeout = setTimeout(
this.showExpiredModal,
this.showExpiredModal.bind(this),
(this.expiryAge + 1) * 1000
)
}

setDataset() {
console.log('setDataset')
this.expiryAge = parseInt(this.element.dataset.expiryAge)
this.warnTime = parseInt(this.element.dataset.warnTime)
console.log('this.expiryAge', this.expiryAge)
console.log('this.warnTime', this.warnTime)
console.log('this.expiryAge is: ', this.expiryAge)
console.log('this.warnTime is: ', this.warnTime)
console.log('Expire modal opens after: ', this.expiryAge + 1)
}

showWarningModal() {
Expand Down Expand Up @@ -113,6 +113,7 @@ class SessionTimeout {
this.restartNoActivity.bind(this),
30 * 1000
)
// SESSION_COOKIE_AGE in seconds - (minus) 30 = warnTime
}

restartNoActivity() {
Expand Down

0 comments on commit 8d795dc

Please sign in to comment.