-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathauth.js
34 lines (28 loc) · 890 Bytes
/
auth.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const jwt = require('jsonwebtoken')
exports.createJWT = function(dbObject){
return jwt.sign({ id: dbObject.dataValues.id }, process.env.SECRETKEY);
}
exports.cookieOptions = function(){
//Cookie should be good for 48 hours
let jsonObject = {
maxAge: 172800000,
httpOnly: true
}
return jsonObject
}
exports.setProviderIDCookie = function(dbObject, resObject){
token = jwt.sign({ id: dbObject.dataValues.id }, process.env.SECRETKEY);
cookieOptions = {
maxAge: 172800000,
httpOnly: true
};
resObject.cookie('jwtToken', token, cookieOptions);
}
exports.setPharmacyIDCookie = function(dbObject, resObject){
token = jwt.sign({ id: dbObject.dataValues.id }, process.env.SECRETKEY);
cookieOptions = {
maxAge: 172800000,
httpOnly: true
};
resObject.cookie('jwtToken', token, cookieOptions);
}