mirror of
https://github.com/strapi/strapi.git
synced 2025-07-31 21:09:39 +00:00
Added default options to enable re-use
This commit is contained in:
parent
2f881274d7
commit
3d9ba865f5
@ -9,6 +9,8 @@
|
||||
const _ = require('lodash');
|
||||
const jwt = require('jsonwebtoken');
|
||||
|
||||
const defaultJwtOptions = { expiresIn: '30d' };
|
||||
|
||||
module.exports = {
|
||||
getToken: function (ctx) {
|
||||
const params = _.assign({}, ctx.request.body, ctx.request.query);
|
||||
@ -36,12 +38,12 @@ module.exports = {
|
||||
return this.verify(token);
|
||||
},
|
||||
|
||||
issue: (payload) => {
|
||||
issue: (payload, jwtOptions) => {
|
||||
_.defaults(jwtOptions, defaultJwtOptions);
|
||||
return jwt.sign(
|
||||
_.clone(payload.toJSON ? payload.toJSON() : payload),
|
||||
process.env.JWT_SECRET || _.get(strapi.plugins['users-permissions'], 'config.jwtSecret') || 'oursecret', {
|
||||
expiresIn: '30d'
|
||||
}
|
||||
process.env.JWT_SECRET || _.get(strapi.plugins['users-permissions'], 'config.jwtSecret') || 'oursecret',
|
||||
jwtOptions,
|
||||
);
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user