Skip to content

Commit 3009021

Browse files
committed
fix: allow overriding the auth plugin serverAlias
The auth plugin should allow the serverAlias to be overwritten in the options in the same way that the service plugin currently does.
1 parent cc45810 commit 3009021

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/auth-module/auth-module.ts renamed to src/auth-module/make-auth-plugin.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ eslint
33
@typescript-eslint/explicit-function-return-type: 0,
44
@typescript-eslint/no-explicit-any: 0
55
*/
6+
import { FeathersVuexOptions } from '../service-module/types'
67
import setupState from './auth-module.state'
78
import setupGetters from './auth-module.getters'
89
import setupMutations from './auth-module.mutations'
@@ -19,13 +20,13 @@ const defaults = {
1920
actions: {} // for custom actions
2021
}
2122

22-
export default function authPluginInit(feathersClient) {
23+
export default function authPluginInit(feathersClient, globalOptions: FeathersVuexOptions) {
2324
if (!feathersClient || !feathersClient.service) {
2425
throw new Error('You must pass a Feathers Client instance to feathers-vuex')
2526
}
2627

27-
return function createAuthModule(options) {
28-
options = Object.assign({}, defaults, options)
28+
return function makeAuthPlugin(options) {
29+
options = Object.assign({}, defaults, { serverAlias: globalOptions.serverAlias }, options)
2930

3031
if (!feathersClient.authenticate) {
3132
throw new Error(

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ eslint
33
@typescript-eslint/explicit-function-return-type: 0,
44
@typescript-eslint/no-explicit-any: 0
55
*/
6-
import setupAuthPlugin from './auth-module/auth-module'
76
import FeathersVuexFind from './FeathersVuexFind'
87
import FeathersVuexGet from './FeathersVuexGet'
98
import makeFindMixin from './make-find-mixin'
@@ -12,6 +11,7 @@ import { globalModels as models } from './service-module/global-models'
1211
import { clients, addClient } from './service-module/global-clients'
1312
import makeModel from './service-module/make-model'
1413
import prepareMakeServicePlugin from './service-module/make-service-plugin'
14+
import prepareMakeAuthPlugin from './auth-module/make-auth-plugin'
1515

1616
import { FeathersVuexOptions } from './service-module/types'
1717
import { initAuth } from './utils'
@@ -52,11 +52,12 @@ export default function feathersVuex(feathers, options: FeathersVuexOptions) {
5252

5353
const BaseModel = makeModel(options)
5454
const makeServicePlugin = prepareMakeServicePlugin(options)
55+
const makeAuthPlugin = prepareMakeAuthPlugin(feathers, options)
5556

5657
return {
5758
makeServicePlugin,
5859
BaseModel,
59-
makeAuthPlugin: setupAuthPlugin(feathers),
60+
makeAuthPlugin,
6061
FeathersVuex,
6162
models,
6263
clients

0 commit comments

Comments
 (0)