mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
547 B
25 lines
547 B
import { store } from 'nuxt3-store' |
|
import type { Api } from 'nocodb-sdk' |
|
import { useNuxtApp } from '#app' |
|
|
|
const user = store({ |
|
name: 'user', |
|
type: 'localstorage', |
|
value: { token: null, user: null }, |
|
reactiveType: 'reactive', |
|
version: '1.0.0', |
|
}) |
|
|
|
export const useUser = () => { |
|
const { $api } = useNuxtApp() |
|
|
|
const getUser = async (...args: Parameters<Api<any>['auth']['me']>) => { |
|
user.user = await $api.auth.me(...args) |
|
} |
|
|
|
const setToken = (token) => { |
|
user.token = token |
|
} |
|
|
|
return { user, setToken, getUser } |
|
}
|
|
|