Open animir opened 5 years ago
Thanks for reporting! Do you have a suggestion how to fix it? :)
@rwieruch Hi, I am not GraphQL expert, but I do have an idea.
I'd do next check on the backend before getting me
object:
let me = {};
if (req.body.operationName !== 'signUp' && req.body.operationName !== 'signIn') {
me = await getMe(req);
}
And those operations should be named on client:
const SIGN_UP = gql`
mutation signUp( ...
What do you think?
I think we can fix this issue like this.
const getMe = async req => {
const token = req.headers['x-token'];
if (token) {
try {
return await jwt.verify(token, process.env.SECRET);
} catch (e) {
// throw new AuthenticationError(
// 'Your session expired. Sign in again.',
// );
}
}
return null;
};
signUp
and signIn
)
If token is expired, there is no way to SignUp, as it tries to use current token.
See
getMe
method inindex.js