chore: Set token expiration time to 14 days
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
9926e5589e
commit
ecc9239bfe
@@ -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 };
|
||||
}
|
||||
|
Reference in New Issue
Block a user