@@ -9,25 +9,30 @@ export default function makeAuthActions (feathersClient) {
9
9
}
10
10
return feathersClient . authenticate ( data )
11
11
. then ( response => {
12
- commit ( 'setAccessToken' , response . accessToken )
12
+ if ( response . accessToken ) {
13
+ commit ( 'setAccessToken' , response . accessToken )
13
14
14
- // Decode the token and set the payload, but return the response
15
- return feathersClient . passport . verifyJWT ( response . accessToken )
16
- . then ( payload => {
17
- commit ( 'setPayload' , payload )
15
+ // Decode the token and set the payload, but return the response
16
+ return feathersClient . passport . verifyJWT ( response . accessToken )
17
+ . then ( payload => {
18
+ commit ( 'setPayload' , payload )
18
19
19
- // Populate the user if the userService was provided
20
- if ( state . userService && payload . hasOwnProperty ( 'userId' ) ) {
21
- return dispatch ( 'populateUser' , payload . userId )
22
- . then ( ( ) => {
23
- commit ( 'unsetAuthenticatePending' )
24
- return response
25
- } )
26
- } else {
27
- commit ( 'unsetAuthenticatePending' )
28
- }
29
- return response
30
- } )
20
+ // Populate the user if the userService was provided
21
+ if ( state . userService && payload . hasOwnProperty ( 'userId' ) ) {
22
+ return dispatch ( 'populateUser' , payload . userId )
23
+ . then ( ( ) => {
24
+ commit ( 'unsetAuthenticatePending' )
25
+ return response
26
+ } )
27
+ } else {
28
+ commit ( 'unsetAuthenticatePending' )
29
+ }
30
+ return response
31
+ } )
32
+ // If there was not an accessToken in the response, allow the response to pass through to handle two-factor-auth
33
+ } else {
34
+ return response
35
+ }
31
36
} )
32
37
. catch ( error => {
33
38
commit ( 'setAuthenticateError' , error )
0 commit comments