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>pull/2364/head
Pranav C
2 years ago
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