feat: basic oauth

This commit is contained in:
Anthony Fu 2022-11-15 23:48:23 +08:00
parent 72b13f5265
commit 7ab17001f0
16 changed files with 199 additions and 106 deletions

View file

@ -1,19 +1,11 @@
import { login } from 'masto'
export const DEFAULT_SERVER = 'mas.to'
export default defineNuxtPlugin((nuxt) => {
const server = useCookie('nuxtodon-server')
const token = useCookie('nuxtodon-token')
const { server, token } = useAppCookies()
const masto = login({
url: `https://${server.value || DEFAULT_SERVER}`,
url: `https://${server.value}`,
accessToken: token.value,
})
nuxt.vueApp.provide('masto', masto)
// Reload the page when the token changes
watch(token, () => {
location.reload()
})
})