allow login without token

if our proxy sends proxy auth headers, lets still try to log in even
though we have no bearer token.
This commit is contained in:
Igor Serebryany 2023-10-06 14:34:12 -07:00
parent 3f7ba82e6a
commit a85ae7467c
No known key found for this signature in database
GPG key ID: 0AF607692FD9EB24

View file

@ -170,17 +170,17 @@ export default {
this.processing = false this.processing = false
}, },
checkAuth() { checkAuth() {
const headers = {}
const token = localStorage.getItem('token') const token = localStorage.getItem('token')
if (!token) return false if (token) {
headers.Authorization = `Bearer ${token}`
}
this.processing = true this.processing = true
return this.$axios return this.$axios
.$post('/api/authorize', null, { .$post('/api/authorize', null, { headers })
headers: {
Authorization: `Bearer ${token}`
}
})
.then((res) => { .then((res) => {
this.setUser(res) this.setUser(res)
this.processing = false this.processing = false
@ -214,11 +214,14 @@ export default {
} }
}, },
async mounted() { async mounted() {
if (localStorage.getItem('token')) { var userfound = await this.checkAuth()
var userfound = await this.checkAuth()
if (userfound) return // if valid user no need to check status // if valid user no need to check status
if (userfound) {
return
} else {
this.checkStatus()
} }
this.checkStatus()
} }
} }
</script> </script>