Skip to content

Commit 51ea4f0

Browse files
Merge pull request #462 from hamiltoes/fix-auth-response-mutating-state
Fix: Auth module responseHandler modifying state outside of mutation
2 parents fcf6963 + 55dde58 commit 51ea4f0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/auth-module/auth-module.actions.ts

Lines changed: 3 additions & 1 deletion
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 fastCopy from 'fast-copy'
67
import { globalModels as models } from '../service-module/global-models'
78
import { getNameFromPath } from '../utils'
89

@@ -41,7 +42,8 @@ export default function makeAuthActions(feathersClient) {
4142
.map(modelName => models[state.serverAlias][modelName])
4243
.find(model => getNameFromPath(model.servicePath) === getNameFromPath(state.userService))
4344
if (Model) {
44-
user = new Model(user)
45+
// Copy user object to avoid setupInstance modifying payload state
46+
user = new Model(fastCopy(user))
4547
}
4648
}
4749
commit('setUser', user)

0 commit comments

Comments
 (0)