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 {connect} from 'react-redux'
|
||||||
import {bindActionCreators} from 'redux'
|
import {bindActionCreators} from 'redux'
|
||||||
import {withRouter} from 'react-router'
|
import {withRouter} from 'react-router'
|
||||||
|
@ -22,67 +22,81 @@ const handleClickLogin = props => organization => async e => {
|
||||||
router.push('')
|
router.push('')
|
||||||
}
|
}
|
||||||
|
|
||||||
const Purgatory = ({
|
class Purgatory extends Component {
|
||||||
name,
|
componentWillUpdate() {
|
||||||
provider,
|
const {router, me} = this.props
|
||||||
scheme,
|
|
||||||
currentOrganization,
|
|
||||||
meChangeOrganization,
|
|
||||||
roles,
|
|
||||||
organizations,
|
|
||||||
logoutLink,
|
|
||||||
router,
|
|
||||||
links,
|
|
||||||
superAdmin,
|
|
||||||
}) => {
|
|
||||||
const rolesAndOrgs = organizations.map(organization => ({
|
|
||||||
organization,
|
|
||||||
role: getRoleNameByOrgID(organization.id, roles),
|
|
||||||
currentOrganization: organization.id === currentOrganization.id,
|
|
||||||
}))
|
|
||||||
|
|
||||||
const subHeading =
|
if (me === null) {
|
||||||
rolesAndOrgs.length === 1
|
router.push('/login')
|
||||||
? 'Authenticated in 1 Organization'
|
}
|
||||||
: `Authenticated in ${rolesAndOrgs.length} Organizations`
|
}
|
||||||
|
|
||||||
return (
|
render() {
|
||||||
<div>
|
const {me, meChangeOrganization, logoutLink, router, links} = this.props
|
||||||
<Notifications />
|
|
||||||
<SplashPage>
|
if (me === null) {
|
||||||
<div className="auth--purgatory">
|
return null
|
||||||
<h3>
|
}
|
||||||
{name}
|
|
||||||
</h3>
|
const {
|
||||||
<h6>
|
name,
|
||||||
{subHeading}{' '}
|
provider,
|
||||||
<code>
|
scheme,
|
||||||
{scheme}/{provider}
|
currentOrganization,
|
||||||
</code>
|
roles,
|
||||||
</h6>
|
organizations,
|
||||||
{rolesAndOrgs.length
|
superAdmin,
|
||||||
? <div className="auth--list">
|
} = me
|
||||||
{rolesAndOrgs.map((rag, i) =>
|
|
||||||
<PurgatoryAuthItem
|
const rolesAndOrgs = organizations.map(organization => ({
|
||||||
key={i}
|
organization,
|
||||||
roleAndOrg={rag}
|
role: getRoleNameByOrgID(organization.id, roles),
|
||||||
superAdmin={superAdmin}
|
currentOrganization: organization.id === currentOrganization.id,
|
||||||
onClickLogin={handleClickLogin({
|
}))
|
||||||
router,
|
|
||||||
links,
|
const subHeading =
|
||||||
meChangeOrganization,
|
rolesAndOrgs.length === 1
|
||||||
})}
|
? 'Authenticated in 1 Organization'
|
||||||
/>
|
: `Authenticated in ${rolesAndOrgs.length} Organizations`
|
||||||
)}
|
|
||||||
</div>
|
return (
|
||||||
: <p>You are a Lost Soul</p>}
|
<div>
|
||||||
<a href={logoutLink} className="btn btn-sm btn-link auth--logout">
|
<Notifications />
|
||||||
Logout
|
<SplashPage>
|
||||||
</a>
|
<div className="auth--purgatory">
|
||||||
</div>
|
<h3>
|
||||||
</SplashPage>
|
{name}
|
||||||
</div>
|
</h3>
|
||||||
)
|
<h6>
|
||||||
|
{subHeading}{' '}
|
||||||
|
<code>
|
||||||
|
{scheme}/{provider}
|
||||||
|
</code>
|
||||||
|
</h6>
|
||||||
|
{rolesAndOrgs.length
|
||||||
|
? <div className="auth--list">
|
||||||
|
{rolesAndOrgs.map((rag, i) =>
|
||||||
|
<PurgatoryAuthItem
|
||||||
|
key={i}
|
||||||
|
roleAndOrg={rag}
|
||||||
|
superAdmin={superAdmin}
|
||||||
|
onClickLogin={handleClickLogin({
|
||||||
|
router,
|
||||||
|
links,
|
||||||
|
meChangeOrganization,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
: <p>You are a Lost Soul</p>}
|
||||||
|
<a href={logoutLink} className="btn btn-sm btn-link auth--logout">
|
||||||
|
Logout
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</SplashPage>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const {arrayOf, bool, func, shape, string} = PropTypes
|
const {arrayOf, bool, func, shape, string} = PropTypes
|
||||||
|
@ -94,54 +108,36 @@ Purgatory.propTypes = {
|
||||||
links: shape({
|
links: shape({
|
||||||
me: string,
|
me: string,
|
||||||
}),
|
}),
|
||||||
name: string.isRequired,
|
me: shape({
|
||||||
provider: string.isRequired,
|
|
||||||
scheme: string.isRequired,
|
|
||||||
currentOrganization: shape({
|
|
||||||
id: string.isRequired,
|
|
||||||
name: string.isRequired,
|
name: string.isRequired,
|
||||||
}).isRequired,
|
provider: string.isRequired,
|
||||||
roles: arrayOf(
|
scheme: string.isRequired,
|
||||||
shape({
|
currentOrganization: shape({
|
||||||
name: string,
|
id: string.isRequired,
|
||||||
organization: string,
|
name: string.isRequired,
|
||||||
})
|
}).isRequired,
|
||||||
).isRequired,
|
roles: arrayOf(
|
||||||
organizations: arrayOf(
|
shape({
|
||||||
shape({
|
name: string,
|
||||||
id: string,
|
organization: string,
|
||||||
name: string,
|
})
|
||||||
})
|
).isRequired,
|
||||||
).isRequired,
|
organizations: arrayOf(
|
||||||
logoutLink: string.isRequired,
|
shape({
|
||||||
|
id: string,
|
||||||
|
name: string,
|
||||||
|
})
|
||||||
|
).isRequired,
|
||||||
|
superAdmin: bool,
|
||||||
|
}),
|
||||||
|
logoutLink: string,
|
||||||
meChangeOrganization: func.isRequired,
|
meChangeOrganization: func.isRequired,
|
||||||
superAdmin: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapStateToProps = ({
|
const mapStateToProps = ({links, auth: {me, logoutLink}}) => ({
|
||||||
links,
|
links,
|
||||||
auth: {
|
|
||||||
me: {
|
|
||||||
name,
|
|
||||||
provider,
|
|
||||||
scheme,
|
|
||||||
currentOrganization,
|
|
||||||
roles,
|
|
||||||
organizations,
|
|
||||||
superAdmin,
|
|
||||||
},
|
|
||||||
logoutLink,
|
|
||||||
},
|
|
||||||
}) => ({
|
|
||||||
links,
|
|
||||||
name,
|
|
||||||
provider,
|
|
||||||
scheme,
|
|
||||||
currentOrganization,
|
|
||||||
roles,
|
|
||||||
organizations,
|
|
||||||
logoutLink,
|
logoutLink,
|
||||||
superAdmin,
|
me,
|
||||||
})
|
})
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
const mapDispatchToProps = dispatch => ({
|
||||||
|
|
Loading…
Reference in New Issue