refactor: Use input params for all mutations
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
212523aec6
commit
bb36748764
@@ -3,18 +3,20 @@ import jwt from 'jsonwebtoken';
|
||||
import appConfig from '../../config/app';
|
||||
|
||||
type Params = {
|
||||
email: string;
|
||||
password: string;
|
||||
input: {
|
||||
email: string;
|
||||
password: string;
|
||||
};
|
||||
};
|
||||
|
||||
const TOKEN_EXPIRES_IN = '14d';
|
||||
|
||||
const login = async (_parent: unknown, params: Params) => {
|
||||
const user = await User.query().findOne({
|
||||
email: params.email,
|
||||
email: params.input.email,
|
||||
});
|
||||
|
||||
if (user && (await user.login(params.password))) {
|
||||
if (user && (await user.login(params.input.password))) {
|
||||
const token = jwt.sign({ userId: user.id }, appConfig.appSecretKey, {
|
||||
expiresIn: TOKEN_EXPIRES_IN,
|
||||
});
|
||||
|
Reference in New Issue
Block a user