Skip to content

Commit

Permalink
Increase expiry time for devices token
Browse files Browse the repository at this point in the history
  • Loading branch information
lluis-protofy-xyz committed Nov 7, 2024
1 parent 615ed4a commit ec4734b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/protonode/src/lib/crypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import jwt from 'jsonwebtoken';
export const hash = async (password: string) => bcrypt.hash(password, 10)
export const checkPassword = async (password: string, hash: string) => bcrypt.compare(password, hash)

export const genToken = (data:any) => {
return jwt.sign(data, process.env.TOKEN_SECRET ?? '', { expiresIn: '3600000s' });
export const genToken = (data:any,options:any={ expiresIn: '3600000s' }) => {
return jwt.sign(data, process.env.TOKEN_SECRET ?? '', options);
}

export const verifyToken = (token: string) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/protonode/src/lib/serviceToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export const getServiceToken = () => {
}

export const getDeviceToken = (deviceId,isAdmin:boolean=false) =>{
return genToken({id: deviceId, type: 'device', admin: isAdmin===false?false:true})
return genToken({id: deviceId, type: 'device', admin: isAdmin},{expiresIn: '100y'})
}

0 comments on commit ec4734b

Please sign in to comment.