import React, { Component } from 'react';
import { connect } from 'react-redux';
import { replace } from 'react-router-redux';
import userManager from './userManager';
import log from 'domain/log';

class SingleSignOnRedirectCallback extends Component {
  componentDidMount() {
    userManager.signinRedirectCallback()
        .then(() => {
          this.props.dispatch(replace(sessionStorage.lastUrlPath || ''));
        })
        .catch((error) => {
          log.error('SingleSignOnRedirectCallback - Could not sign in', error);
          return userManager.signoutRedirect();
        });
  }

  render() {
    return null;
  }
}

SingleSignOnRedirectCallback.propTypes = {
  dispatch: React.PropTypes.func.isRequired,
};

export default connect()(SingleSignOnRedirectCallback);

import React, { Component } from 'react';
import { connect } from 'react-redux';
import { replace } from 'react-router-redux';
import userManager from './userManager';

class SingleSignOnRedirectCallback extends Component {
  componentDidMount() {
    userManager.signinRedirectCallback() // TODO What if it fails?
        .then(() => {
          this.props.dispatch(replace(sessionStorage.lastUrlPath || ''));
        });
  }

  render() {
    return null;
  }
}

SingleSignOnRedirectCallback.propTypes = {
  dispatch: React.PropTypes.func.isRequired,
};

export default connect()(SingleSignOnRedirectCallback);

Revert "Added a catch() in case the redirect callback fails"
Revert "Added a catch() in case the redirect callback fails"

This reverts commit fea916641be1c19b398d79bdbf4c4dc7e1af21e3.
