Browse Source

feat(gui-v2): add `refreshToken` to global actions

pull/2877/head
braks 2 years ago
parent
commit
db3142729b
  1. 4
      packages/nc-gui-v2/composables/useGlobal/actions.ts
  2. 1
      packages/nc-gui-v2/composables/useGlobal/types.ts

4
packages/nc-gui-v2/composables/useGlobal/actions.ts

@ -2,7 +2,9 @@ import { notification } from 'ant-design-vue'
import type { Actions, State } from './types'
import { useNuxtApp } from '#imports'
export function useGlobalActions(state: State) {
export function useGlobalActions(state: State): Actions {
// todo replace with just `new Api()`? Would solve recursion issues
/** we have to use the globally injected api instance, otherwise we run into recursion as `useApi` calls `useGlobal` */
const { $api } = useNuxtApp()
/** Sign out by deleting the token from localStorage */

1
packages/nc-gui-v2/composables/useGlobal/types.ts

@ -29,6 +29,7 @@ export interface Getters {
export interface Actions {
signOut: () => void
signIn: (token: string) => void
refreshToken: () => void
}
export type ReadonlyState = Readonly<Pick<State, 'token' | 'user'>> & Omit<State, 'token' | 'user'>

Loading…
Cancel
Save