diff --git a/api/src/index.js b/api/src/index.js
index 04eab61d7..6c61ceed8 100644
--- a/api/src/index.js
+++ b/api/src/index.js
@@ -64,8 +64,18 @@ const resolvers = {
return ctx.db.query.member({ where: { authId: arg.authId } }, info)
},
async currentMember(parent, args, ctx, info) {
- console.log('currentMember: ', ctx.request.res.req.user)
+ console.log('currentMember: ', ctx.request.res.req.user, ctx.token)
const authId = ctx.request.res.req.user.sub
+
+ fetch('URL_GOES_HERE', {
+ method: 'post',
+ headers: new Headers({
+ 'Authorization': 'Basic '+btoa('username:password'),
+ 'Content-Type': 'application/x-www-form-urlencoded'
+ }),
+ body: 'A=1&B=2'
+ })
+
return ctx.db.query.member({ where: { authId } }, info)
},
teams(parent, args, ctx, info) {
diff --git a/client/src/App.js b/client/src/App.js
index 2fdbb7578..1fd6e8cb8 100644
--- a/client/src/App.js
+++ b/client/src/App.js
@@ -64,6 +64,7 @@ wsClient.onReconnected(() => {
})
const httpLink = new HttpLink({ uri: graphqlEndpoint })
+const httpUserLink = new HttpLink({ uri: 'http://104.43.240.255:4000/graphql' })
const link = split(
({ query }) => {
@@ -134,6 +135,11 @@ export const client = new ApolloClient({
connectToDevTools: true
})
+export const UserClient = new ApolloClient({
+ link: ApolloLink.from([authRetryLink, authLink, httpUserLink]),
+ cache
+})
+
export const auth = new Auth(
result => console.log('auth result', result),
client
diff --git a/client/src/graphql/members/GetUserByAuthIDQuery.js b/client/src/graphql/members/GetUserByAuthIDQuery.js
new file mode 100644
index 000000000..14375c2f1
--- /dev/null
+++ b/client/src/graphql/members/GetUserByAuthIDQuery.js
@@ -0,0 +1,25 @@
+/* eslint-disable no-unused-vars */
+import gql from 'graphql-tag'
+
+export const USER_BY_AUTHID = gql`
+query($authId: String){
+ userByAuthId (authId: $authId){
+ id
+ alias
+ firstName
+ middleName
+ lastName
+ bio
+ email
+ emailVerified
+ isDeveloper
+ isDataAnalyst
+ isTrader
+ role {
+ id
+ }
+ }
+}
+`
+
+export default USER_BY_AUTHID
diff --git a/client/src/graphql/members/index.js b/client/src/graphql/members/index.js
index a53b48a41..7ff5637c7 100644
--- a/client/src/graphql/members/index.js
+++ b/client/src/graphql/members/index.js
@@ -1,3 +1,4 @@
import { GetCurrentMember } from './GetCurrentMemberQuery'
+import { USER_BY_AUTHID } from './GetUserByAuthIDQuery'
-export { GetCurrentMember }
+export { GetCurrentMember, USER_BY_AUTHID }
diff --git a/client/src/views/navbar/LoggedIn.js b/client/src/views/navbar/LoggedIn.js
index e8408d1b6..242feefb1 100644
--- a/client/src/views/navbar/LoggedIn.js
+++ b/client/src/views/navbar/LoggedIn.js
@@ -1,17 +1,22 @@
import React from 'react'
import PropTypes from 'prop-types'
-import { graphql } from 'react-apollo'
+import { Query } from 'react-apollo'
import LoggedInMenu from './LoggedInMenu'
-import { GetCurrentMember } from '../../graphql/members'
+import { UserClient } from '../../App'
+import { USER_BY_AUTHID } from '../../graphql/members'
import { isDefined } from '../../utils/js-helpers'
export const LoggedIn = props => {
let { data, user, auth } = props
- console.log('LoggedIn :', data, user)
+ console.log('LoggedIn :', data, user, auth)
let displayName = 'No Display Name'
+ let authId = null
+ if (isDefined(user.authId)) {
+ authId = user.authId
+ }
if (isDefined(user.alias)) {
displayName = user.alias
@@ -29,12 +34,38 @@ export const LoggedIn = props => {
displayName = user.firstName + ' ' + user.lastName
}
+ if (authId === null) {
+ return (
+
Loading...
+ )
+ }
+
return (
-
+
+ {({ loading, error, data }) => {
+ console.log('USER_BY_AUTHID: ', loading, error, data)
+
+ if (loading) {
+ return Loading...
+ }
+
+ if (error) {
+ error.graphQLErrors.map(({ message }, i) => {
+ return {message}
+ })
+ }
+ return (
+
+
+
+ )
+ }}
+
)
}
@@ -44,4 +75,4 @@ LoggedIn.propTypes = {
auth: PropTypes.object.isRequired
}
-export default graphql(GetCurrentMember)(LoggedIn) // This binds the querty to the component
+export default LoggedIn
diff --git a/client/src/views/navbar/LoggedInMenu.js b/client/src/views/navbar/LoggedInMenu.js
index 574a8e0ed..6c1fb266c 100644
--- a/client/src/views/navbar/LoggedInMenu.js
+++ b/client/src/views/navbar/LoggedInMenu.js
@@ -1,16 +1,29 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
+import { withStyles } from '@material-ui/core/styles'
+
import Button from '@material-ui/core/Button'
import Menu from '@material-ui/core/Menu'
import MenuItem from '@material-ui/core/MenuItem'
+import Drawer from '@material-ui/core/Drawer'
import { Link } from 'react-router-dom'
import ProfileIcon from '@material-ui/icons/Person'
import LogoutIcon from '@material-ui/icons/DirectionsWalk'
-const UserLink = props =>
+import UserProfile from './Profile'
+
const LogoutLink = props =>
+const styles = {
+ drawer: {
+ width: 250
+ },
+ fullList: {
+ width: 'auto'
+ }
+}
+
class LoggedInUserMenu extends Component {
constructor (props) {
super(props)
@@ -18,14 +31,16 @@ class LoggedInUserMenu extends Component {
this.handleMenu = this.handleMenu.bind(this)
this.handleClose = this.handleClose.bind(this)
this.handleLogout = this.handleLogout.bind(this)
+ this.toggleDrawer = this.toggleDrawer.bind(this)
this.state = {
- menu: null
+ menu: null,
+ open: false
}
}
render () {
- const { menuLabel } = this.props
+ const { menuLabel, user, classes } = this.props
return (
)
}
@@ -67,11 +91,17 @@ class LoggedInUserMenu extends Component {
this.props.auth.logout()
this.setState({ menu: null })
}
+
+ toggleDrawer () {
+ this.setState({ open: !this.state.open })
+ }
}
LoggedInUserMenu.propTypes = {
+ classes: PropTypes.object.isRequired,
menuLabel: PropTypes.string.isRequired,
- auth: PropTypes.object.isRequired
+ auth: PropTypes.object.isRequired,
+ user: PropTypes.object
}
-export default LoggedInUserMenu
+export default withStyles(styles)(LoggedInUserMenu)
diff --git a/client/src/views/navbar/Profile.js b/client/src/views/navbar/Profile.js
new file mode 100644
index 000000000..adbef1761
--- /dev/null
+++ b/client/src/views/navbar/Profile.js
@@ -0,0 +1,94 @@
+import React, { Component } from 'react'
+import PropTypes from 'prop-types'
+
+// Materia UI
+
+import { withStyles } from '@material-ui/core/styles'
+import Button from '@material-ui/core/Button'
+import Grid from '@material-ui/core/Grid'
+import Card from '@material-ui/core/Card'
+import CardContent from '@material-ui/core/CardContent'
+import CardMedia from '@material-ui/core/CardMedia'
+import Typography from '@material-ui/core/Typography'
+import Divider from '@material-ui/core/Divider'
+
+// Images
+
+const styles = theme => ({
+ root: {
+ flexGrow: 1,
+ padding: 60,
+ margin: 2
+ },
+ card: {
+ maxWidth: 240,
+ minWidth: 240,
+ paddingTop: '30'
+ },
+ media: {
+ paddingTop: '56.25%', // 16:9,
+ marginTop: '30',
+ width: 100,
+ height: 100,
+ maxWidth: 100
+ },
+ grid: {
+ paddingTop: '30',
+ marginTop: '30'
+ },
+ typography: {
+ width: '100%',
+ marginTop: 20,
+ marginBottom: 20
+ }
+
+})
+
+class UserProfile extends Component {
+ render () {
+ const { classes, user, toggleDrawer } = this.props
+ return (
+
+
+
+
+
+
+
+
+ { user.firstName } { user.lastName } ( {user.alias} )
+
+
+
+
+ { user.role.name }
+
+
+
+
+ { user.bio }
+
+
+
+
+
+ )
+ }
+}
+
+UserProfile.propTypes = {
+ classes: PropTypes.object.isRequired,
+ user: PropTypes.object,
+ toggleDrawer: PropTypes.func
+}
+export default withStyles(styles)(UserProfile)