mirror of
https://github.com/plankanban/planka.git
synced 2025-07-21 14:19:44 +02:00
parent
dab38cbc18
commit
7786533a90
40 changed files with 273 additions and 133 deletions
29
server/api/helpers/utils/create-token.js
Normal file
29
server/api/helpers/utils/create-token.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
const jwt = require('jsonwebtoken');
|
||||
|
||||
module.exports = {
|
||||
sync: true,
|
||||
|
||||
inputs: {
|
||||
subject: {
|
||||
type: 'json',
|
||||
required: true,
|
||||
},
|
||||
issuedAt: {
|
||||
type: 'ref',
|
||||
},
|
||||
},
|
||||
|
||||
fn(inputs) {
|
||||
const { issuedAt = new Date() } = inputs;
|
||||
const iat = Math.floor(issuedAt / 1000);
|
||||
|
||||
return jwt.sign(
|
||||
{
|
||||
iat,
|
||||
sub: inputs.subject,
|
||||
exp: iat + sails.config.custom.tokenExpiresIn * 24 * 60 * 60,
|
||||
},
|
||||
sails.config.session.secret,
|
||||
);
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue