marshallswain / feathers-pinia

Connect your Feathers API to the elegant data store for Vue
52 stars 22 forks source link

add User type to useAuth composable #167

Closed jd1378 closed 5 months ago

jd1378 commented 6 months ago

Hi currently the type of user in useAuth store is any it would be nice if we could pass in our user type using a second parameter like AuthenticateData:

// src/stores/auth.ts
import { acceptHMRUpdate, defineStore } from 'pinia'
import { useAuth } from 'feathers-pinia'
import type { MyUser } from './somewhere'

interface AuthenticateData {
    strategy: 'jwt' | 'local';
    accessToken?: string;
    email?: string;
    password?: string;
}

export const useAuthStore = defineStore('auth', () => {
  const { api } = useFeathers()

  const utils = useAuth<AuthenticateData, MyUser>({ api }) // <----------- what I mean

  utils.reAuthenticate()

  return { ...utils }
})

Also it would be nice if you also export AuthenticateData, as I am adding a otpToken, and I find it nicer if I could just extend it's type instead of copying and editing it :)