File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -20,14 +20,14 @@ interface UseAuthOptions {
2020 onLogoutError ?: ErrorHandler
2121}
2222
23- interface AuthenticateData {
23+ export interface AuthenticateData {
2424 strategy : 'jwt' | 'local'
2525 accessToken ?: string
2626 email ?: string
2727 password ?: string
2828}
2929
30- export function useAuth < d = AuthenticateData > ( options : UseAuthOptions ) {
30+ export function useAuth < d = AuthenticateData , U = any > ( options : UseAuthOptions ) {
3131 const { api, servicePath, skipTokenCheck } = options
3232 const entityService = servicePath ? api . service ( servicePath ) : null
3333 const entityKey = options . entityKey || 'user'
@@ -47,7 +47,7 @@ export function useAuth<d = AuthenticateData>(options: UseAuthOptions) {
4747
4848 // user
4949 const userId = ref < NullableId > ( null )
50- const user = computed ( ( ) => {
50+ const user = computed < U | null > ( ( ) => {
5151 if ( ! entityService || ! userId . value )
5252 return null
5353 const u = entityService ?. store . itemsById [ userId . value ]
Original file line number Diff line number Diff line change @@ -51,8 +51,13 @@ describe('useAuth in Pinia store', () => {
5151 password ?: string
5252 }
5353
54+ interface User {
55+ id : number ;
56+ email : string ;
57+ }
58+
5459 defineStore ( 'auth' , ( ) => {
55- const utils = useAuth < AuthenticateData > ( { api } )
60+ const utils = useAuth < AuthenticateData , User > ( { api } )
5661 utils . reAuthenticate ( )
5762 return { ...utils }
5863 } )
You can’t perform that action at this time.
0 commit comments