Skip to content
Snippets Groups Projects
Commit 3f517f86 authored by Dominik Seeger's avatar Dominik Seeger :ghost: Committed by robinwilliam.hundt
Browse files

Resolve "Show dialog when user did not log out"

parent c66ef3da
Branches
Tags
No related merge requests found
Pipeline #107813 passed
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
"test:unit": "vue-cli-service test:unit --require mock-local-storage" "test:unit": "vue-cli-service test:unit --require mock-local-storage"
}, },
"dependencies": { "dependencies": {
"@sentry/browser": "^5.6.3",
"@sentry/integrations": "^5.6.1",
"axios": "^0.18.0", "axios": "^0.18.0",
"file-saver": "^2.0.2", "file-saver": "^2.0.2",
"highlight.js": "^9.12.0", "highlight.js": "^9.12.0",
......
...@@ -71,6 +71,16 @@ export default class AutoLogout extends Vue { ...@@ -71,6 +71,16 @@ export default class AutoLogout extends Vue {
} }
mounted () { mounted () {
// show notification on unload if logged in
window.onbeforeunload = event => {
if (Authentication.isLoggedIn) {
// return something to trigger the confirmation dialog
// since firefox 44 it is no longer possible to show a custom confirmation message
event.preventDefault()
event.returnValue = ''
}
}
this.timer = setInterval(() => { this.timer = setInterval(() => {
const timeDialogAppearsBeforeLogout = Math.min(600 * 1e3, const timeDialogAppearsBeforeLogout = Math.min(600 * 1e3,
this.jwtTimeDelta ? this.jwtTimeDelta * 0.3 : Infinity) this.jwtTimeDelta ? this.jwtTimeDelta * 0.3 : Infinity)
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
> >
{{ lineNo }} {{ lineNo }}
</v-btn> </v-btn>
</v-btn>
</td> </td>
<td class="code-cell-content pl-2"> <td class="code-cell-content pl-2">
<span v-html="code" class="code-line"></span> <span v-html="code" class="code-line"></span>
......
...@@ -8,6 +8,8 @@ import router from './router/index' ...@@ -8,6 +8,8 @@ import router from './router/index'
import Vuetify from 'vuetify' import Vuetify from 'vuetify'
import Notifications from 'vue-notification' import Notifications from 'vue-notification'
import Clipboard from 'v-clipboard' import Clipboard from 'v-clipboard'
import * as Sentry from '@sentry/browser'
import * as Integrations from '@sentry/integrations'
import 'vuetify/dist/vuetify.min.css' import 'vuetify/dist/vuetify.min.css'
...@@ -17,6 +19,19 @@ Vue.use(Vuetify) ...@@ -17,6 +19,19 @@ Vue.use(Vuetify)
Vue.use(Clipboard) Vue.use(Clipboard)
Vue.use(Notifications) Vue.use(Notifications)
if (process.env.NODE_ENV === 'test') {
Sentry.init({
dsn: 'https://c86a983153da412b8aec8b8df9ce51ba@robin-in.space/2',
integrations: [new Integrations.Vue({Vue, attachProps: true, logErrors: true})],
})
} else if (process.env.NODE_ENV == 'production') {
Sentry.init({
dsn: 'https://874b896335564d8c9c49137391f8e3f1@robin-in.space/3',
integrations: [new Integrations.Vue({Vue, attachProps: true, logErrors: true})],
})
}
Vue.config.productionTip = false Vue.config.productionTip = false
const el = process.env.NODE_ENV === 'test' ? undefined : '#app' const el = process.env.NODE_ENV === 'test' ? undefined : '#app'
......
...@@ -73,7 +73,7 @@ export default { ...@@ -73,7 +73,7 @@ export default {
this.loading = true this.loading = true
Auth.getJWT(this.credentials).then(() => { Auth.getJWT(this.credentials).then(() => {
return Promise.all([ return Promise.all([
Auth.getUser(), Auth.getUser(),
Auth.getJWTTimeDelta() Auth.getJWTTimeDelta()
]) ])
}).then(() => { }).then(() => {
......
...@@ -112,6 +112,67 @@ ...@@ -112,6 +112,67 @@
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b" resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b"
integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw== integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==
"@sentry/browser@^5.6.3":
version "5.6.3"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-5.6.3.tgz#5cc37b0443eba55ad13c13d34d6b95ff30dfbfe3"
integrity sha512-bP1LTbcKPOkkmfJOAM6c7WZ0Ov0ZEW6B9keVZ9wH9fw/lBPd9UyDMDCwJ+FAYKz9M9S5pxQeJ4Ebd7WUUrGVAQ==
dependencies:
"@sentry/core" "5.6.2"
"@sentry/types" "5.6.1"
"@sentry/utils" "5.6.1"
tslib "^1.9.3"
"@sentry/core@5.6.2":
version "5.6.2"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.6.2.tgz#8c5477654a83ebe41a72e86a79215deb5025e418"
integrity sha512-grbjvNmyxP5WSPR6UobN2q+Nss7Hvz+BClBT8QTr7VTEG5q89TwNddn6Ej3bGkaUVbct/GpVlI3XflWYDsnU6Q==
dependencies:
"@sentry/hub" "5.6.1"
"@sentry/minimal" "5.6.1"
"@sentry/types" "5.6.1"
"@sentry/utils" "5.6.1"
tslib "^1.9.3"
"@sentry/hub@5.6.1":
version "5.6.1"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.6.1.tgz#9f355c0abcc92327fbd10b9b939608aa4967bece"
integrity sha512-m+OhkIV5yTAL3R1+XfCwzUQka0UF/xG4py8sEfPXyYIcoOJ2ZTX+1kQJLy8QQJ4RzOBwZA+DzRKP0cgzPJ3+oQ==
dependencies:
"@sentry/types" "5.6.1"
"@sentry/utils" "5.6.1"
tslib "^1.9.3"
"@sentry/integrations@^5.6.1":
version "5.6.1"
resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-5.6.1.tgz#fcee1a6e5535a07fdefd365178662283279ce0d7"
integrity sha512-bPtJbmhLDH9Exy0luIKxjlfqmuyAjUPTHZ2CLIw6YlhA5WgK9aYyyjLHTmWK+E9baZBqSp0ShVPAgue2jfpQmQ==
dependencies:
"@sentry/types" "5.6.1"
"@sentry/utils" "5.6.1"
tslib "^1.9.3"
"@sentry/minimal@5.6.1":
version "5.6.1"
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.6.1.tgz#09d92b26de0b24555cd50c3c33ba4c3e566009a1"
integrity sha512-ercCKuBWHog6aS6SsJRuKhJwNdJ2oRQVWT2UAx1zqvsbHT9mSa8ZRjdPHYOtqY3DoXKk/pLUFW/fkmAnpdMqRw==
dependencies:
"@sentry/hub" "5.6.1"
"@sentry/types" "5.6.1"
tslib "^1.9.3"
"@sentry/types@5.6.1":
version "5.6.1"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.6.1.tgz#5915e1ee4b7a678da3ac260c356b1cb91139a299"
integrity sha512-Kub8TETefHpdhvtnDj3kKfhCj0u/xn3Zi2zIC7PB11NJHvvPXENx97tciz4roJGp7cLRCJsFqCg4tHXniqDSnQ==
"@sentry/utils@5.6.1":
version "5.6.1"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.6.1.tgz#69d9e151e50415bc91f2428e3bcca8beb9bc2815"
integrity sha512-rfgha+UsHW816GqlSRPlniKqAZylOmQWML2JsujoUP03nPu80zdN43DK9Poy/d9OxBxv0gd5K2n+bFdM2kqLQQ==
dependencies:
"@sentry/types" "5.6.1"
tslib "^1.9.3"
"@sinonjs/commons@^1.0.2", "@sinonjs/commons@^1.2.0": "@sinonjs/commons@^1.0.2", "@sinonjs/commons@^1.2.0":
version "1.3.0" version "1.3.0"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.3.0.tgz#50a2754016b6f30a994ceda6d9a0a8c36adda849" resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.3.0.tgz#50a2754016b6f30a994ceda6d9a0a8c36adda849"
...@@ -7412,6 +7473,11 @@ tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0: ...@@ -7412,6 +7473,11 @@ tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ== integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==
tslib@^1.9.3:
version "1.10.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==
tslint@^5.12.0: tslint@^5.12.0:
version "5.12.1" version "5.12.1"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.12.1.tgz#8cec9d454cf8a1de9b0a26d7bdbad6de362e52c1" resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.12.1.tgz#8cec9d454cf8a1de9b0a26d7bdbad6de362e52c1"
......
...@@ -52,9 +52,8 @@ class TestFeedbackUpdate(LiveServerTestCase): ...@@ -52,9 +52,8 @@ class TestFeedbackUpdate(LiveServerTestCase):
# open a new tab and go to the validation page of the just corrected submission # open a new tab and go to the validation page of the just corrected submission
self.browser.execute_script('window.open()') self.browser.execute_script('window.open()')
self.browser.switch_to.window(self.browser.window_handles[-1]) self.browser.switch_to.window(self.browser.window_handles[-1])
second_tab = self.browser.current_window_handle
self.browser.execute_script("window.sessionStorage.clear()")
self.browser.get(self.live_server_url) self.browser.get(self.live_server_url)
second_tab = self.browser.current_window_handle
username = 'other_tut' username = 'other_tut'
password = 'p' password = 'p'
fact.UserAccountFactory( fact.UserAccountFactory(
......
...@@ -17,7 +17,9 @@ from django.core.exceptions import ObjectDoesNotExist ...@@ -17,7 +17,9 @@ from django.core.exceptions import ObjectDoesNotExist
def create_browser() -> webdriver.Firefox: def create_browser() -> webdriver.Firefox:
options = Options() options = Options()
options.headless = bool(os.environ.get('HEADLESS_TESTS', False)) options.headless = bool(os.environ.get('HEADLESS_TESTS', False))
options.set_capability('unhandledPromptBehavior', 'accept')
profile = FirefoxProfile() profile = FirefoxProfile()
profile.set_preference("dom.disable_beforeunload", True)
profile.set_preference("browser.download.folderList", 2) profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.download.dir", os.path.dirname(__file__)) profile.set_preference("browser.download.dir", os.path.dirname(__file__))
profile.set_preference("browser.download.useDownloadDir", True) profile.set_preference("browser.download.useDownloadDir", True)
...@@ -39,11 +41,14 @@ def login(browser, live_server_url, username, password='p'): ...@@ -39,11 +41,14 @@ def login(browser, live_server_url, username, password='p'):
WebDriverWait(browser, 10).until(ec.url_contains('/home')) WebDriverWait(browser, 10).until(ec.url_contains('/home'))
def logout(browser: webdriver.Firefox):
browser.find_element_by_id('logout').click()
def reset_browser_after_test(browser: webdriver.Firefox, live_server_url): def reset_browser_after_test(browser: webdriver.Firefox, live_server_url):
while len(browser.window_handles) > 1: while len(browser.window_handles) > 1:
browser.close() browser.close()
browser.switch_to.window(browser.window_handles[0]) browser.switch_to.window(browser.window_handles[-1])
browser.execute_script("window.sessionStorage.clear()")
browser.get(live_server_url) browser.get(live_server_url)
......
...@@ -3,6 +3,14 @@ import string ...@@ -3,6 +3,14 @@ import string
from .default import REST_FRAMEWORK from .default import REST_FRAMEWORK
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
sentry_sdk.init(
dsn='https://874b896335564d8c9c49137391f8e3f1@robin-in.space/3',
integrations=[DjangoIntegration()]
)
""" A live configuration for enhanced security """ """ A live configuration for enhanced security """
CSRF_COOKIE_SECURE = True CSRF_COOKIE_SECURE = True
CSRF_COOKIE_HTTPONLY = True CSRF_COOKIE_HTTPONLY = True
......
from .default import * from .default import *
from .live import * from .live import *
sentry_sdk.init(
dsn='https://c86a983153da412b8aec8b8df9ce51ba@robin-in.space/2',
integrations=[DjangoIntegration()]
)
REST_FRAMEWORK['DEFAULT_THROTTLE_RATES']['anon'] = '1000/minute' REST_FRAMEWORK['DEFAULT_THROTTLE_RATES']['anon'] = '1000/minute'
...@@ -13,3 +13,4 @@ xlrd~=1.2.0 ...@@ -13,3 +13,4 @@ xlrd~=1.2.0
xkcdpass==1.17.0 xkcdpass==1.17.0
django-constance[database]~=2.3.1 django-constance[database]~=2.3.1
semver~=2.8.1 semver~=2.8.1
sentry-sdk==0.11.2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment