mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-12-23 23:49:53 +01:00
Fix kicker triggering & Show a notification when kicked-out
This commit is contained in:
parent
3778977c94
commit
26511954c4
@ -36,7 +36,7 @@
|
||||
function protectedRoute(route) {
|
||||
let bool = false
|
||||
route.meta.middlewares?.forEach(func => {
|
||||
if (func instanceof Function && func.name == 'auth') {
|
||||
if (func instanceof Function && func.name == 'authGuard') {
|
||||
bool = true
|
||||
return
|
||||
}
|
||||
|
@ -42,11 +42,12 @@
|
||||
// }, 1000);
|
||||
}
|
||||
|
||||
// Triggers the user logout
|
||||
function logoutUser() {
|
||||
clearTimeout(logoutTimer.value)
|
||||
console.log('inativity detected, user kicked out')
|
||||
|
||||
user.logout()
|
||||
user.logout({ kicked: true})
|
||||
}
|
||||
|
||||
function resetTimer() {
|
||||
|
@ -212,7 +212,7 @@
|
||||
|
||||
if (copied) {
|
||||
if(user.preferences.kickUserAfter == -1 && (permit_closing || false) === true) {
|
||||
user.logout()
|
||||
user.logout({ kicked: true})
|
||||
}
|
||||
else if(user.preferences.closeOtpOnCopy && (permit_closing || false) === true) {
|
||||
emit("please-close-me");
|
||||
|
@ -78,7 +78,7 @@ export const httpClientFactory = (endpoint = 'api') => {
|
||||
// We catch the 418 response and log the user out
|
||||
if (error.response.status === 418) {
|
||||
const user = useUserStore()
|
||||
user.logout()
|
||||
user.logout({ kicked: true})
|
||||
}
|
||||
|
||||
useNotifyStore().error(error)
|
||||
|
13
resources/js_vue3/stores/user.js
vendored
13
resources/js_vue3/stores/user.js
vendored
@ -4,6 +4,7 @@ import router from '@/router'
|
||||
import { useColorMode } from '@vueuse/core'
|
||||
import { useTwofaccounts } from '@/stores/twofaccounts'
|
||||
import { useGroups } from '@/stores/groups'
|
||||
import { useNotifyStore } from '@/stores/notify'
|
||||
|
||||
export const useUserStore = defineStore({
|
||||
id: 'user',
|
||||
@ -55,7 +56,9 @@ export const useUserStore = defineStore({
|
||||
/**
|
||||
* Logs the user out or moves to proxy logout url
|
||||
*/
|
||||
logout() {
|
||||
logout(options = {}) {
|
||||
const { kicked } = options
|
||||
|
||||
// async appLogout(evt) {
|
||||
if (this.$2fauth.config.proxyAuth) {
|
||||
if (this.$2fauth.config.proxyLogoutUrl) {
|
||||
@ -66,11 +69,13 @@ export const useUserStore = defineStore({
|
||||
else {
|
||||
return authService.logout().then(() => {
|
||||
this.reset()
|
||||
if (kicked) {
|
||||
const notify = useNotifyStore()
|
||||
notify.clear()
|
||||
notify.warn({ text: trans('auth.autolock_triggered_punchline'), duration:-1 })
|
||||
}
|
||||
})
|
||||
|
||||
// this.$router.push({ name: 'login', params: { forceRefresh: true } })
|
||||
}
|
||||
// },
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -166,7 +166,7 @@
|
||||
|
||||
if (copied) {
|
||||
if(user.preferences.kickUserAfter == -1) {
|
||||
user.logout()
|
||||
user.logout({ kicked: true})
|
||||
}
|
||||
notify.success({ text: trans('commons.copied_to_clipboard') })
|
||||
}
|
||||
|
@ -27,8 +27,7 @@
|
||||
'register' => 'Register',
|
||||
'welcome_to_2fauth' => 'Welcome to 2FAuth',
|
||||
'autolock_triggered' => 'Auto lock triggered',
|
||||
'autolock_triggered_punchline' => 'The event watched by the Auto Lock feature has fired. You\'ve been automatically disconnected.',
|
||||
'change_autolock_in_settings' => 'You can change the behavior of the Autolock feature in Settings > Options tab.',
|
||||
'autolock_triggered_punchline' => 'You\'ve been automatically disconnected.',
|
||||
'already_authenticated' => 'Already authenticated, please log out first',
|
||||
'authentication' => 'Authentication',
|
||||
'maybe_later' => 'Maybe later',
|
||||
|
Loading…
Reference in New Issue
Block a user