mirror of https://github.com/nocodb/nocodb
Browse Source
use a generic function to populate jwt token to avoid repetition re #2361 Signed-off-by: Pranav C <pranavxc@gmail.com>feat/0523-export-schema
Pranav C
2 years ago
committed by
Raju Udava
3 changed files with 24 additions and 50 deletions
@ -0,0 +1,18 @@
|
||||
import * as jwt from 'jsonwebtoken'; |
||||
import User from '../../../models/User'; |
||||
import { NcConfig } from '../../../../interface/config'; |
||||
|
||||
export function genJwt(user: User, config: NcConfig) { |
||||
return jwt.sign( |
||||
{ |
||||
email: user.email, |
||||
firstname: user.firstname, |
||||
lastname: user.lastname, |
||||
id: user.id, |
||||
roles: user.roles, |
||||
token_version: user.token_version |
||||
}, |
||||
config.auth.jwt.secret, |
||||
config.auth.jwt.options |
||||
); |
||||
} |
Loading…
Reference in new issue