Skip to content

Commit

Permalink
Pass user agent to api client
Browse files Browse the repository at this point in the history
  • Loading branch information
chvp committed Aug 17, 2023
1 parent c0eab6f commit b5ecf2a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions env.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="vite/client" />

declare module '@sqlite.org/sqlite-wasm'

declare const APP_VERSION: string
5 changes: 4 additions & 1 deletion src/stores/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export const useAuthStore = defineStore('auth', () => {

async function login(data: { name: string; password: string }) {
try {
const result = await api.auth_tokens.create(data)
const result = await api.auth_tokens.create({
...data,
auth_token: { user_agent: `AccentorWeb/${APP_VERSION} on ${navigator.userAgent}` }
})
secret.value = result.secret
deviceId.value = result.device_id
userId.value = result.user_id
Expand Down
1 change: 0 additions & 1 deletion src/views/AppRootView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ watchEffect(() => {
function logout() {
authStore.logout()
}
</script>

<template>
Expand Down
2 changes: 1 addition & 1 deletion src/views/LoginView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function submit() {
<v-toolbar-title>Login</v-toolbar-title>
</v-toolbar>
<v-card-text>
// TODO(chvp): errors
<!-- TODO(chvp): errors -->
<v-form @submit.prevent="submit">
<v-text-field
v-model="name"
Expand Down
3 changes: 3 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export default defineConfig({
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
define: {
APP_VERSION: JSON.stringify(process.env.npm_package_version)
},
server: {
headers: {
'Cross-Origin-Opener-Policy': 'same-origin',
Expand Down

0 comments on commit b5ecf2a

Please sign in to comment.