Skip to content

Commit fde1b23

Browse files
committed
Fix: initAuth utility updated for Feathers V4
This fixes the `initAuth` utility for SSR when the feathersClient is provided as one of the options. It now calls Feathers Authentication V4 methods.
1 parent b02201a commit fde1b23

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ export const initAuth = function initAuth(options) {
174174
commit(`${moduleName}/setAccessToken`, accessToken)
175175
commit(`${moduleName}/setPayload`, payload)
176176
if (feathersClient) {
177-
return feathersClient.passport.setJWT(accessToken).then(() => payload)
177+
return feathersClient.authentication
178+
.setAccessToken(accessToken)
179+
.then(() => payload)
178180
}
179181
}
180182
return Promise.resolve(payload)

test/utils.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,16 @@ describe('Utils', function() {
6060
commit: store.commit,
6161
req,
6262
moduleName: 'auth',
63-
cookieName: 'feathers-jwt'
63+
cookieName: 'feathers-jwt',
64+
feathersClient
6465
})
6566
.then(() => {
6667
assert(
6768
store.state.auth.accessToken === accessToken,
6869
'the token was in place'
6970
)
7071
assert(store.state.auth.payload, 'the payload was set')
71-
// @ts-ignore
72-
return feathersClient.passport.getJWT()
72+
return feathersClient.authentication.getAccessToken()
7373
})
7474
.then(token => {
7575
assert.isDefined(token, 'the feathers client storage was set')

0 commit comments

Comments
 (0)