update
parent
4b5dd61525
commit
ebccbf270f
9
index.js
9
index.js
|
@ -12,6 +12,7 @@ const DEFAULT_CONFIG = {
|
||||||
ttl: 3600 * 24 * 7,
|
ttl: 3600 * 24 * 7,
|
||||||
domain: '', // NODESSID域, 默认等于domain
|
domain: '', // NODESSID域, 默认等于domain
|
||||||
level: 0, // 校验级别, 0: 不校验客户端, 2: ua, 4: ip, 6: ua + ip
|
level: 0, // 校验级别, 0: 不校验客户端, 2: ua, 4: ip, 6: ua + ip
|
||||||
|
secret: 'it_is_secret_key', // jwt密钥, 使用时请修改
|
||||||
db: {
|
db: {
|
||||||
host: '127.0.0.1',
|
host: '127.0.0.1',
|
||||||
port: 6379,
|
port: 6379,
|
||||||
|
@ -23,8 +24,12 @@ const DEFAULT_CONFIG = {
|
||||||
export const SessionModule = {
|
export const SessionModule = {
|
||||||
name: 'session',
|
name: 'session',
|
||||||
install(conf = {}) {
|
install(conf = {}) {
|
||||||
if (!conf.domain) {
|
if (!conf.secret) {
|
||||||
throw new Error('Please make sure to set the `domain` field')
|
console.warn(
|
||||||
|
new Error(
|
||||||
|
'You must set a `secret` key for session, or it will use the default key.'
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
let session = Object.assign({}, DEFAULT_CONFIG, conf)
|
let session = Object.assign({}, DEFAULT_CONFIG, conf)
|
||||||
this.set({ session })
|
this.set({ session })
|
||||||
|
|
Loading…
Reference in New Issue