mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-29 00:10:54 +05:30
Fix permissions page
This commit is contained in:
parent
232cf0465c
commit
5820a50047
@ -1,5 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
import { FormattedMessage as Message } from 'react-intl';
|
||||||
|
|
||||||
import icons from 'components/ui/icons.scss';
|
import icons from 'components/ui/icons.scss';
|
||||||
import { PanelBodyHeader } from 'components/ui/Panel';
|
import { PanelBodyHeader } from 'components/ui/Panel';
|
||||||
import BaseAuthBody from 'components/auth/BaseAuthBody';
|
import BaseAuthBody from 'components/auth/BaseAuthBody';
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
line-height: 9px;
|
line-height: 9px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 6px;
|
top: 6px;
|
||||||
left: 0;
|
left: -4px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ export default class Button extends FormComponent {
|
|||||||
PropTypes.string
|
PropTypes.string
|
||||||
]).isRequired,
|
]).isRequired,
|
||||||
block: PropTypes.bool,
|
block: PropTypes.bool,
|
||||||
color: PropTypes.oneOf(['green', 'blue', 'red', 'lightViolet', 'darkBlue', 'violet'])
|
color: PropTypes.oneOf(['green', 'blue', 'red', 'lightViolet', 'darkBlue', 'violet', 'orange'])
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -83,7 +83,7 @@ export default class AuthFlow {
|
|||||||
this.run('setOAuthRequest', {});
|
this.run('setOAuthRequest', {});
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (path.replace(/(.)\/.+/, '$1')) { // use only first part of an url
|
switch (path) { // use only first part of an url
|
||||||
case '/oauth':
|
case '/oauth':
|
||||||
this.setState(new OAuthState());
|
this.setState(new OAuthState());
|
||||||
break;
|
break;
|
||||||
@ -92,10 +92,6 @@ export default class AuthFlow {
|
|||||||
this.setState(new RegisterState());
|
this.setState(new RegisterState());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '/recover-password':
|
|
||||||
this.setState(new RecoverPasswordState());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '/forgot-password':
|
case '/forgot-password':
|
||||||
this.setState(new ForgotPasswordState());
|
this.setState(new ForgotPasswordState());
|
||||||
break;
|
break;
|
||||||
@ -115,7 +111,14 @@ export default class AuthFlow {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unsupported request: ${path}`);
|
switch (path.replace(/(.)\/.+/, '$1')) { // use only first part of an url
|
||||||
|
case '/recover-password':
|
||||||
|
this.setState(new RecoverPasswordState());
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new Error(`Unsupported request: ${path}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
import AuthFlow from 'services/authFlow/AuthFlow';
|
import AuthFlow from 'services/authFlow/AuthFlow';
|
||||||
import AbstractState from 'services/authFlow/AbstractState';
|
import AbstractState from 'services/authFlow/AbstractState';
|
||||||
|
|
||||||
|
import OAuthState from 'services/authFlow/OAuthState';
|
||||||
|
import RegisterState from 'services/authFlow/RegisterState';
|
||||||
|
import RecoverPasswordState from 'services/authFlow/RecoverPasswordState';
|
||||||
|
import ForgotPasswordState from 'services/authFlow/ForgotPasswordState';
|
||||||
|
import ResendActivationState from 'services/authFlow/ResendActivationState';
|
||||||
|
import LoginState from 'services/authFlow/LoginState';
|
||||||
|
|
||||||
// TODO: navigate and state switching
|
// TODO: navigate and state switching
|
||||||
|
|
||||||
describe('AuthFlow', () => {
|
describe('AuthFlow', () => {
|
||||||
@ -140,4 +147,45 @@ describe('AuthFlow', () => {
|
|||||||
sinon.assert.calledWithExactly(state.reject, flow, expectedPayload);
|
sinon.assert.calledWithExactly(state.reject, flow, expectedPayload);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#handleRequest()', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
sinon.stub(flow, 'setState');
|
||||||
|
sinon.stub(flow, 'run');
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.entries({
|
||||||
|
'/': LoginState,
|
||||||
|
'/login': LoginState,
|
||||||
|
'/password': LoginState,
|
||||||
|
'/activation': LoginState,
|
||||||
|
'/change-password': LoginState,
|
||||||
|
'/oauth/permissions': LoginState,
|
||||||
|
'/oauth/finish': LoginState,
|
||||||
|
'/oauth': OAuthState,
|
||||||
|
'/register': RegisterState,
|
||||||
|
'/recover-password': RecoverPasswordState,
|
||||||
|
'/recover-password/key123': RecoverPasswordState,
|
||||||
|
'/forgot-password': ForgotPasswordState,
|
||||||
|
'/resend-activation': ResendActivationState
|
||||||
|
}).forEach(([path, type]) => {
|
||||||
|
it(`should transition to ${type.name} if ${path}`, () => {
|
||||||
|
flow.handleRequest(path);
|
||||||
|
|
||||||
|
sinon.assert.calledOnce(flow.setState);
|
||||||
|
sinon.assert.calledWithExactly(flow.setState, sinon.match.instanceOf(type));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should run setOAuthRequest if /', () => {
|
||||||
|
flow.handleRequest('/');
|
||||||
|
|
||||||
|
sinon.assert.calledOnce(flow.run);
|
||||||
|
sinon.assert.calledWithExactly(flow.run, 'setOAuthRequest', {});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('throws if unsupported request', () => {
|
||||||
|
expect(() => flow.handleRequest('/foo/bar')).to.throw('Unsupported request: /foo/bar');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user