chore: Set token expiration time to 14 days

This commit is contained in:
Faruk AYDIN
2022-03-06 18:45:24 +03:00
committed by Ömer Faruk Aydın
parent 9926e5589e
commit ecc9239bfe

View File

@@ -7,13 +7,17 @@ type Params = {
password: string;
};
const TOKEN_EXPIRES_IN = '14d';
const login = async (_parent: unknown, params: Params) => {
const user = await User.query().findOne({
email: params.email,
});
if (user && (await user.login(params.password))) {
const token = jwt.sign({ userId: user.id }, appConfig.appSecretKey);
const token = jwt.sign({ userId: user.id }, appConfig.appSecretKey, {
expiresIn: TOKEN_EXPIRES_IN,
});
return { token, user };
}