| 1234567891011121314151617181920212223242526 |
- export default defineNuxtPlugin({
- name: 'auth',
- async setup(nuxtApp) {
- const { isAuthenticated, isPlaymate, restoreAuth, refreshAuth, refreshUser, refreshPlaymateInfo } = useAuth()
- nuxtApp.hook('app:mounted', () => {
- watch(isAuthenticated, (newIsAuthenticated) => {
- if (newIsAuthenticated) {
- refreshAuth()
- refreshUser()
- }
- }, {
- immediate: false,
- })
- watch(isPlaymate, (newIsPlaymate) => {
- if (newIsPlaymate) {
- refreshPlaymateInfo()
- }
- }, {
- immediate: false,
- })
- restoreAuth()
- })
- },
- })
|