chore: Use currentUser from authentication

This commit is contained in:
Faruk AYDIN
2021-10-14 16:38:03 +02:00
committed by Ali BARIN
parent bdd0843d94
commit 5be9ff8383
4 changed files with 18 additions and 22 deletions

View File

@@ -1,18 +1,14 @@
import { GraphQLNonNull, GraphQLInt } from 'graphql';
import Credential from '../../models/credential';
import authLinkType from '../types/auth-link';
import User from '../../models/user';
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
type Params = {
credentialId: number,
}
const createAuthLinkResolver = async (params: Params) => {
const user = await User.query().findOne({
email: 'user@automatisch.com'
})
const createAuthLinkResolver = async (params: Params, req: RequestWithCurrentUser) => {
const credential = await Credential.query().findOne({
user_id: user.id,
user_id: req.currentUser.id,
id: params.credentialId
})
@@ -29,7 +25,7 @@ const createAuthLink = {
args: {
credentialId: { type: GraphQLNonNull(GraphQLInt) },
},
resolve: (_: any, params: Params) => createAuthLinkResolver(params)
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => createAuthLinkResolver(params, req)
};
export default createAuthLink;