Skip to content

Commit 4aff535

Browse files
committed
new: export AuthState interface so users can augment FeathersVuexStoreState
1 parent 15f9f82 commit 4aff535

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

src/auth-module/auth-module.state.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ eslint
33
@typescript-eslint/explicit-function-return-type: 0,
44
@typescript-eslint/no-explicit-any: 0
55
*/
6+
import { AuthState } from './types'
7+
68
export default function setupAuthState({
79
userService,
810
serverAlias,
911
responseEntityField = 'user',
1012
entityIdField = 'userId'
1113
}) {
12-
const state = {
14+
const state: AuthState = {
1315
accessToken: null, // The JWT
1416
payload: null, // The JWT payload
1517
entityIdField,
@@ -21,6 +23,7 @@ export default function setupAuthState({
2123
errorOnAuthenticate: null,
2224
errorOnLogout: null,
2325
user: null, // For a reactive user object, use the `user` getter.
26+
userService: null,
2427
serverAlias
2528
}
2629
// If a userService string was passed, add a user attribute

src/auth-module/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ export interface AuthState {
22
accessToken: string
33
payload: {}
44
entityIdField: string
5+
responseEntityField: string
56

67
isAuthenticatePending: boolean
78
isLogoutPending: boolean
89

910
errorOnAuthenticate: Error
1011
errorOnLogout: Error
1112
user: {}
13+
userService: string
14+
serverAlias: string
1215
}

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
import { initAuth, hydrateApi } from './utils'
3535
import { FeathersVuex } from './vue-plugin/vue-plugin'
3636
import { ServiceState } from './service-module/service-module.state'
37+
import { AuthState } from './auth-module/types'
3738
const events = ['created', 'patched', 'updated', 'removed']
3839

3940
const defaults: FeathersVuexOptions = {
@@ -107,6 +108,7 @@ export {
107108
clients,
108109
useFind,
109110
useGet,
111+
AuthState,
110112
Id,
111113
Model,
112114
ModelClone,

0 commit comments

Comments
 (0)