Clean-up unused login/logout code in app.vue (#2693)

Removes unused code from app.vue and other occurrences. This code would
be a security issue if used and generates security warnings.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
pull/2695/head
Florian Hotze 2024-08-04 11:40:05 +02:00 committed by GitHub
parent 6b2f264660
commit 0430db5138
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 5 additions and 49 deletions

View File

@ -353,11 +353,6 @@ export default {
// }
},
// Login screen data
serverUrl: '',
username: '',
password: '',
user: null,
sitemaps: null,
@ -385,12 +380,8 @@ export default {
messages: loadLocaleMessages(require.context('@/assets/i18n/about'))
},
computed: {
isAdmin () {
if (!this.$store.getters.apiEndpoint('auth')) return true
return this.ready && this.user && this.user.roles && this.user.roles.indexOf('administrator') >= 0
},
serverDisplayUrl () {
return (this.serverUrl || window.location.origin)
return window.location.origin
}
},
watch: {
@ -541,38 +532,6 @@ export default {
return 'f7:tv'
}
},
login () {
localStorage.setItem('openhab.ui:serverUrl', this.serverUrl)
localStorage.setItem('openhab.ui:username', this.username)
localStorage.setItem('openhab.ui:password', this.password)
this.loadData().then(() => {
this.loggedIn = true
}).catch((err) => {
localStorage.removeItem('openhab.ui:serverUrl')
localStorage.removeItem('openhab.ui:username')
localStorage.removeItem('openhab.ui:password')
this.$f7.dialog.alert('Cannot login, please try again: ' + err)
})
},
logout () {
this.$f7.preloader.show()
this.ready = false
localStorage.removeItem('openhab.ui:serverUrl')
localStorage.removeItem('openhab.ui:username')
localStorage.removeItem('openhab.ui:password')
this.user = null
this.serverUrl = ''
this.username = ''
this.password = ''
this.cleanSession().then(() => {
this.loggedIn = false
this.$f7.views.main.router.navigate('/', { animate: false, clearPreviousHistory: true })
window.location = window.location.origin
}).catch((err) => {
this.$f7.preloader.hide()
this.$f7.dialog.alert('Error while signing out: ' + err)
})
},
updateThemeOptions () {
this.themeOptions.dark = localStorage.getItem('openhab.ui:theme.dark') || ((window.OHApp && window.OHApp.preferDarkMode) ? window.OHApp.preferDarkMode().toString() : (this.$f7.darkTheme ? 'dark' : 'light'))
this.themeOptions.bars = localStorage.getItem('openhab.ui:theme.bars') || 'light'

View File

@ -52,7 +52,7 @@ export default {
resolve(resp.user)
})
}).catch((err) => {
console.log(err)
console.log('Exchanging authorization code failed', err)
reject(err)
})
} else {
@ -83,7 +83,7 @@ export default {
resolve(resp)
})
}).catch((err) => {
console.log(err)
console.log('Refreshing access token failed', err)
reject(err)
})
})
@ -107,7 +107,7 @@ export default {
this.$store.commit('setUser', { user: null })
resolve()
}).catch((err) => {
console.log(err)
console.log('Failed to log out', err)
this.$oh.auth.clearAccessToken()
this.$store.commit('setUser', { user: null })
reject(err)

View File

@ -222,9 +222,6 @@ export default {
},
logout () {
this.$f7.preloader.show()
localStorage.removeItem('openhab.ui:serverUrl')
localStorage.removeItem('openhab.ui:username')
localStorage.removeItem('openhab.ui:password')
this.cleanSession().then(() => {
this.loggedIn = false
this.$f7.views.main.router.navigate('/', { animate: false, clearPreviousHistory: true })

View File

@ -199,7 +199,7 @@ export default {
this.$oh.api.get(`/rest/items/${this.itemName}?metadata=.+`).then((data) => {
this.item = data
this.ready = true
this.iconUrl = (localStorage.getItem('openhab.ui:serverUrl') || '') + '/icon/' + this.item.category + '?format=svg'
this.iconUrl = '/icon/' + this.item.category + '?format=svg'
})
},
deleteItem () {