File tree Expand file tree Collapse file tree 5 files changed +21
-2
lines changed
Expand file tree Collapse file tree 5 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 1717 */
1818
1919window . axios = require ( 'axios' ) ;
20-
2120window . axios . defaults . headers . common [ 'X-Requested-With' ] = 'XMLHttpRequest' ;
21+ window . axios . defaults . headers . common [ 'Accept' ] = 'application/json' ;
2222
2323/**
2424 * Next we will register the CSRF Token as a common header with Axios so that
Original file line number Diff line number Diff line change 6868 email: this .$props .email ,
6969 })
7070 .then (function (response ) {
71+ if (! (response .data instanceof Object )) {
72+ throw new Error (' An error was encountered while processing this request.' );
73+ }
74+
7175 self .$data .submitDisabled = false ;
7276 self .$data .showSpinner = false ;
7377 self .success (response .data .status );
Original file line number Diff line number Diff line change 8181 password: this .$props .user .password ,
8282 })
8383 .then (function (response ) {
84+ // If there is a 302 redirect or some other odd behavior (basically, response that isnt
85+ // in JSON format) throw an error and don't try to continue with the login.
86+ if (! (response .data instanceof Object )) {
87+ throw new Error (' An error was encountered while processing this request.' );
88+ }
89+
8490 if (response .data .complete ) {
8591 return window .location = ' /' ;
8692 }
9298 .catch (function (err ) {
9399 self .$props .user .password = ' ' ;
94100 self .$data .showSpinner = false ;
101+ self .$refs .password .focus ();
102+
95103 if (! err .response ) {
96104 return console .error (err);
97105 }
101109 response .data .errors .forEach (function (error ) {
102110 self .error (error .detail );
103111 });
104- self .$refs .password .focus ();
105112 }
106113 });
107114 },
Original file line number Diff line number Diff line change 9393 token: this .$props .token ,
9494 })
9595 .then (function (response ) {
96+ if (! (response .data instanceof Object )) {
97+ throw new Error (' An error was encountered while processing this login.' );
98+ }
99+
96100 return window .location = response .data .redirect_to ;
97101 })
98102 .catch (function (err ) {
Original file line number Diff line number Diff line change 4949 authentication_code: this .$data .code ,
5050 })
5151 .then (function (response ) {
52+ if (! (response .data instanceof Object )) {
53+ throw new Error (' An error was encountered while processing this login.' );
54+ }
55+
5256 window .location = response .data .intended ;
5357 })
5458 .catch (function (err ) {
You can’t perform that action at this time.
0 commit comments