diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-04-06 09:55:40 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-04-06 09:55:40 -0400 |
| commit | a24eb1cfbd3c294bea39bca53125883c270ca91f (patch) | |
| tree | 4d35ee785a1c1bec9e084668999316a88b863a17 /frontend/components/PleaseSignIn.js | |
| parent | 41a86494f3caea96dd4ed32733310783e47b429d (diff) | |
revert back to @connection
Diffstat (limited to 'frontend/components/PleaseSignIn.js')
| -rw-r--r-- | frontend/components/PleaseSignIn.js | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/frontend/components/PleaseSignIn.js b/frontend/components/PleaseSignIn.js index bd96842..1533dbd 100644 --- a/frontend/components/PleaseSignIn.js +++ b/frontend/components/PleaseSignIn.js @@ -1,19 +1,31 @@ import { Query } from 'react-apollo'; import { CURRENT_USER_QUERY } from '../queries/index'; import Signin from './Signin'; +import Dump from './Dump'; const PleaseSignIn = props => ( <Query query={CURRENT_USER_QUERY}> {({ data }) => { - if (data.me) { - return props.children; + // check if they are signed in + if (!data.me) { + return ( + <div> + <p>Please sign in before continuing!</p> + <Signin /> + </div> + ); } - return ( - <div> - <p>Please sign in before continuing!</p> - <Signin /> - </div> - ); + // check if they need permissions + if (props.allowedPermissions) { + // check if they NO permissions, or they don't meet the requmrenets + if ( + !data.me.permissions || + !props.allowedPermissions.some(permission => data.me.permissions.contains(permission)) + ) { + return <p>Insufficient Permissions to Manage Permissions</p>; + } + } + return props.children; }} </Query> ); |
