mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-27 23:40:28 +05:30
#313: improve logging in auth states
This commit is contained in:
parent
09baa2a398
commit
e9e04d8336
@ -17,7 +17,9 @@ export default class AcceptRulesState extends AbstractState {
|
||||
resolve(context) {
|
||||
context.run('acceptRules')
|
||||
.then(() => context.setState(new CompleteState()))
|
||||
.catch((err = {}) => err.errors || logger.warn(err));
|
||||
.catch((err = {}) =>
|
||||
err.errors || logger.warn('Error accepting rules', err)
|
||||
);
|
||||
}
|
||||
|
||||
reject(context) {
|
||||
|
@ -21,7 +21,9 @@ export default class ActivationState extends AbstractState {
|
||||
resolve(context, payload) {
|
||||
context.run('activate', payload)
|
||||
.then(() => context.setState(new CompleteState()))
|
||||
.catch((err = {}) => err.errors || logger.warn(err));
|
||||
.catch((err = {}) =>
|
||||
err.errors || logger.warn('Error activating account', err)
|
||||
);
|
||||
}
|
||||
|
||||
reject(context) {
|
||||
|
@ -85,7 +85,7 @@ export default class AuthFlow {
|
||||
if (this.onReady) {
|
||||
const callback = this.onReady;
|
||||
this.onReady = () => {};
|
||||
return resp.then(callback, (err) => err || logger.warn(err));
|
||||
return resp.then(callback, (err) => err || logger.warn('State transition error', err));
|
||||
}
|
||||
|
||||
return resp;
|
||||
|
@ -24,7 +24,9 @@ export default class LoginState extends AbstractState {
|
||||
resolve(context, payload) {
|
||||
context.run('login', payload)
|
||||
.then(() => context.setState(new PasswordState()))
|
||||
.catch((err = {}) => err.errors || logger.warn(err));
|
||||
.catch((err = {}) =>
|
||||
err.errors || logger.warn('Error validating login', err)
|
||||
);
|
||||
}
|
||||
|
||||
goBack(context) {
|
||||
|
@ -25,7 +25,9 @@ export default class PasswordState extends AbstractState {
|
||||
login
|
||||
})
|
||||
.then(() => context.setState(new CompleteState()))
|
||||
.catch((err = {}) => err.errors || logger.warn(err));
|
||||
.catch((err = {}) =>
|
||||
err.errors || logger.warn('Error logging in', err)
|
||||
);
|
||||
}
|
||||
|
||||
reject(context) {
|
||||
|
@ -21,7 +21,9 @@ export default class RecoverPasswordState extends AbstractState {
|
||||
resolve(context, payload) {
|
||||
context.run('recoverPassword', payload)
|
||||
.then(() => context.setState(new CompleteState()))
|
||||
.catch((err = {}) => err.errors || logger.warn(err));
|
||||
.catch((err = {}) =>
|
||||
err.errors || logger.warn('Error recovering password', err)
|
||||
);
|
||||
}
|
||||
|
||||
goBack(context) {
|
||||
|
@ -13,7 +13,9 @@ export default class RegisterState extends AbstractState {
|
||||
resolve(context, payload) {
|
||||
context.run('register', payload)
|
||||
.then(() => context.setState(new CompleteState()))
|
||||
.catch((err = {}) => err.errors || logger.warn(err));
|
||||
.catch((err = {}) =>
|
||||
err.errors || logger.warn('Error registering', err)
|
||||
);
|
||||
}
|
||||
|
||||
reject(context, payload) {
|
||||
|
@ -19,7 +19,9 @@ export default class ResendActivationState extends AbstractState {
|
||||
resolve(context, payload) {
|
||||
context.run('resendActivation', payload)
|
||||
.then(() => context.setState(new ActivationState()))
|
||||
.catch((err = {}) => err.errors || logger.warn(err));
|
||||
.catch((err = {}) =>
|
||||
err.errors || logger.warn('Error resending activation', err)
|
||||
);
|
||||
}
|
||||
|
||||
reject(context) {
|
||||
|
@ -65,6 +65,13 @@ const logger = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof context !== 'object') {
|
||||
// it would better to always have an object here
|
||||
context = {
|
||||
message: context
|
||||
};
|
||||
}
|
||||
|
||||
console[method](message, context); // eslint-disable-line
|
||||
|
||||
Raven.captureException(message, {
|
||||
|
@ -14,7 +14,7 @@ describe('<ChangePassword />', () => {
|
||||
|
||||
|
||||
it('should call onSubmit if passwords entered', () => {
|
||||
const onSubmit = sinon.spy().named('onSubmit');
|
||||
const onSubmit = sinon.spy(() => ({catch: () => {}})).named('onSubmit');
|
||||
const component = shallow(<ChangePassword onSubmit={onSubmit} />);
|
||||
|
||||
component.find('Form').simulate('submit');
|
||||
|
Loading…
Reference in New Issue
Block a user