Our technology stack:
- Frontend built with Vue.js and utilizing the vuetify component library
- Custom Python middleware REST API using Flask + Tornado
- External Matomo setup connected to the frontend via the vue-matomo plugin system (https://github.com/AmazingDreams/vue-matomo)
We recently integrated Matamo into our website and have observed an unusual occurrence. Occasionally, out of thousands of users, we noticed that the username and password submitted via a POST request to our middleware is being logged in Matomo as .
Oddly, even though the actual login route is at somesite.com/login, Matamo seems to capture it on the homepage.
Below is the code snippet for authenticating users:
auth.js
const authenticateUser = async (username, password) => {
const body = { username: username, password: password }
const headers = new Headers()
headers.append('Content-Type', 'application/json')
headers.append('Accept', 'application/json')
try {
const response = await fetch('https://somesite.com/users/login', {
method: 'POST',
...(body ? { body: JSON.stringify(body) } : {}),
cache: 'no-store',
credentials: 'include', // this is to allow cross-origin requests to our middleware microservice
headers: headers
})
return response
} catch (error) {
return false
}
}
Login Form
<v-form @submit.prevent="submit" @keyup.native.enter="submit" id="check-login-form">
<v-text-field
class="input-field"
label="MS ID"
v-model="username"
name="username"
data-cy="userName"
prepend-icon="mdi-account"
type="text"
color="rgb(232, 119, 34)"
/>
<div class="password-field">
<v-text-field
class="input-field"
id="password"
data-cy="userPassword"
label="Password"
v-model="password"
name="password"
prepend-icon="mdi-lock"
:type="showPassword ? 'text' : 'password'"
@click:append="showPassword = !showPassword"
color="rgb(232, 119, 34)"
></v-text-field>
<div v-if="showPassword" class="icon-container" v-on:click="toggleShowPassword">
<img src="~assets/Icons/View.svg" class="eye-icon" />
</div>
<div v-else class="icon-container" v-on:click="toggleShowPassword">
<img src="~assets/Icons/ViewHide.svg" class="eye-icon" />
</div>
</div>
</v-form>
Submit Method
async submit() {
this.isLoading = true
const response = await authenticateUser(this.username, this.password)
this.statusCode = response.status
this.currentStatusCode = this.statusCode
if (this.statusCode === 200) {
this.currentStatusCode = this.statusCode
this.$router.push('/')
this.isLoading = false
this.$matomo.setUserId(this.username)
} else {
this.isLoading = false
this.currentStatusCode = null
this.showPassword = false
}
},
toggleShowPassword: function() {
this.showPassword = !this.showPassword
}
},
Any thoughts on why this issue might be occurring?