When user removed from private org, log them out
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>pull/2399/head
parent
236a62f911
commit
64962bb1db
|
@ -1,4 +1,4 @@
|
|||
import React, {PropTypes} from 'react'
|
||||
import React, {PropTypes, Component} from 'react'
|
||||
import {connect} from 'react-redux'
|
||||
import {bindActionCreators} from 'redux'
|
||||
import {withRouter} from 'react-router'
|
||||
|
@ -22,19 +22,32 @@ const handleClickLogin = props => organization => async e => {
|
|||
router.push('')
|
||||
}
|
||||
|
||||
const Purgatory = ({
|
||||
class Purgatory extends Component {
|
||||
componentWillUpdate() {
|
||||
const {router, me} = this.props
|
||||
|
||||
if (me === null) {
|
||||
router.push('/login')
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const {me, meChangeOrganization, logoutLink, router, links} = this.props
|
||||
|
||||
if (me === null) {
|
||||
return null
|
||||
}
|
||||
|
||||
const {
|
||||
name,
|
||||
provider,
|
||||
scheme,
|
||||
currentOrganization,
|
||||
meChangeOrganization,
|
||||
roles,
|
||||
organizations,
|
||||
logoutLink,
|
||||
router,
|
||||
links,
|
||||
superAdmin,
|
||||
}) => {
|
||||
} = me
|
||||
|
||||
const rolesAndOrgs = organizations.map(organization => ({
|
||||
organization,
|
||||
role: getRoleNameByOrgID(organization.id, roles),
|
||||
|
@ -83,6 +96,7 @@ const Purgatory = ({
|
|||
</SplashPage>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const {arrayOf, bool, func, shape, string} = PropTypes
|
||||
|
@ -94,6 +108,7 @@ Purgatory.propTypes = {
|
|||
links: shape({
|
||||
me: string,
|
||||
}),
|
||||
me: shape({
|
||||
name: string.isRequired,
|
||||
provider: string.isRequired,
|
||||
scheme: string.isRequired,
|
||||
|
@ -113,35 +128,16 @@ Purgatory.propTypes = {
|
|||
name: string,
|
||||
})
|
||||
).isRequired,
|
||||
logoutLink: string.isRequired,
|
||||
meChangeOrganization: func.isRequired,
|
||||
superAdmin: bool,
|
||||
}),
|
||||
logoutLink: string,
|
||||
meChangeOrganization: func.isRequired,
|
||||
}
|
||||
|
||||
const mapStateToProps = ({
|
||||
const mapStateToProps = ({links, auth: {me, logoutLink}}) => ({
|
||||
links,
|
||||
auth: {
|
||||
me: {
|
||||
name,
|
||||
provider,
|
||||
scheme,
|
||||
currentOrganization,
|
||||
roles,
|
||||
organizations,
|
||||
superAdmin,
|
||||
},
|
||||
logoutLink,
|
||||
},
|
||||
}) => ({
|
||||
links,
|
||||
name,
|
||||
provider,
|
||||
scheme,
|
||||
currentOrganization,
|
||||
roles,
|
||||
organizations,
|
||||
logoutLink,
|
||||
superAdmin,
|
||||
me,
|
||||
})
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
|
|
Loading…
Reference in New Issue