Auth Id grabbing record from database

This commit is contained in:
Luis Fernando Molina committed 2018-09-07 11:38:00 +02:00
1 parent 2437ac7a31
commit 9e4c86b8d9
3 files changed
+17 -9

No files matched your search

+6 -2
View File
@@ -8,8 +8,12 @@ class LoggedInUser extends Component {
displayLoggedInUser(){
const user = this.props.data.userByAuthId;
console.log(this.props);
console.log(this.props.data);
console.log(this.props.data.userByAuthId);
if(user){
if (user.firstName) {
return(
@@ -45,7 +49,7 @@ export default graphql(getUserByAuthIdQuery, { // What follows is the way to pas
options: (props) => {
return {
variables: {
id: props.authId
authId: props.authId
}
}
}
@@ -55,7 +55,6 @@ class ButtonAppBar extends Component {
let user = JSON.parse(getUser)
const authId = user.sub;
console.log(authId);
this.setState({ authId: authId });
}
+11 -6
View File
@@ -75,17 +75,22 @@ const RootQuery = new GraphQLObjectType({
// Code to get data from data source.
return new Promise((resolve, reject) => {
console.log('args.authId');
console.log(args.authId);
User.findOne({authId: args.authId}, (err, user) => {
if(err) reject(err);
else{
console.log('user.authId');
console.log(user.authId);
if (user.authId === args.authId && user.authId !== undefined) {
console.log(user );
console.log(user.authId );
console.log(args.authId );
console.log(user);
console.log(user);
return resolve(user);
} else {
return null;
}
} else {
return null;
}
}
})
})