mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 17:08:53 +00:00
bug-fix/reset password page (#275)
This commit is contained in:
parent
a47ee32e9f
commit
07400e7d4c
6 changed files with 19 additions and 14 deletions
|
|
@ -17,7 +17,7 @@ describe('AuthenticatedRoutes - component', () => {
|
|||
type: '@@router/CALL_HISTORY_METHOD',
|
||||
payload: {
|
||||
method: 'push',
|
||||
args: ['/reset_password'],
|
||||
args: ['/login/reset'],
|
||||
},
|
||||
};
|
||||
const renderedText = 'This text was rendered';
|
||||
|
|
|
|||
|
|
@ -29,14 +29,14 @@ export class LoginRoutes extends Component {
|
|||
|
||||
render () {
|
||||
const { containerStyles, logoStyles } = componentStyles;
|
||||
const { children } = this.props;
|
||||
const { children, location: { pathname } } = this.props;
|
||||
|
||||
return (
|
||||
<div style={containerStyles}>
|
||||
<img style={logoStyles} alt="Kolide text logo" src="/assets/images/kolide-logo-text.svg" />
|
||||
<LoginPage />
|
||||
<LoginPage pathname={pathname} />
|
||||
<RouteTransition
|
||||
pathname={this.props.location.pathname}
|
||||
pathname={pathname}
|
||||
atEnter={{
|
||||
scale: 1.3,
|
||||
opacity: 0,
|
||||
|
|
@ -61,4 +61,10 @@ export class LoginRoutes extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
export default connect()(LoginRoutes);
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
const { location } = ownProps;
|
||||
|
||||
return { location };
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps)(LoginRoutes);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export class HomePage extends Component {
|
|||
|
||||
return (
|
||||
<div style={containerStyles}>
|
||||
<Avatar size="small" style={avatarStyles} user={user} />
|
||||
{user && <Avatar size="small" style={avatarStyles} user={user} />}
|
||||
<span>You are successfully logged in! </span>
|
||||
{user && <Link to={LOGOUT}>Logout</Link>}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import { push } from 'react-router-redux';
|
|||
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
|
||||
import { clearAuthErrors, loginUser } from '../../redux/nodes/auth/actions';
|
||||
import debounce from '../../utilities/debounce';
|
||||
import local from '../../utilities/local';
|
||||
import LoginForm from '../../components/forms/LoginForm';
|
||||
import LoginSuccessfulPage from '../LoginSuccessfulPage';
|
||||
import paths from '../../router/paths';
|
||||
|
|
@ -14,11 +13,11 @@ import './styles.scss';
|
|||
const WHITELIST_ERRORS = ['Unable to authenticate the current user'];
|
||||
|
||||
export class LoginPage extends Component {
|
||||
|
||||
static propTypes = {
|
||||
dispatch: PropTypes.func,
|
||||
error: PropTypes.string,
|
||||
loading: PropTypes.bool,
|
||||
pathname: PropTypes.string,
|
||||
user: PropTypes.object,
|
||||
};
|
||||
|
||||
|
|
@ -30,11 +29,10 @@ export class LoginPage extends Component {
|
|||
}
|
||||
|
||||
componentWillMount () {
|
||||
const { dispatch } = this.props;
|
||||
const { dispatch, pathname, user } = this.props;
|
||||
const { HOME, LOGIN } = paths;
|
||||
|
||||
if (local.getItem('auth_token')) {
|
||||
return dispatch(push('/'));
|
||||
}
|
||||
if (user && pathname === LOGIN) return dispatch(push(HOME));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ describe('LoginPage - component', () => {
|
|||
|
||||
it('redirects to the home page', () => {
|
||||
const mockStore = reduxMockStore({ auth: { user } });
|
||||
const props = { pathname: '/login' };
|
||||
const redirectAction = {
|
||||
type: '@@router/CALL_HISTORY_METHOD',
|
||||
payload: {
|
||||
|
|
@ -48,7 +49,7 @@ describe('LoginPage - component', () => {
|
|||
},
|
||||
};
|
||||
|
||||
mount(connectedComponent(LoginPage, { mockStore }));
|
||||
mount(connectedComponent(LoginPage, { props, mockStore }));
|
||||
expect(mockStore.getActions()).toInclude(redirectAction);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ export default {
|
|||
HOME: '/',
|
||||
LOGIN: '/login',
|
||||
LOGOUT: '/logout',
|
||||
RESET_PASSWORD: '/reset_password',
|
||||
RESET_PASSWORD: '/login/reset',
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue