internals.applyRoutes = function(server, next) {
server.state('user', {
isSecure: false,
path: '/',
encoding: 'base64json'
});
server.route([
{
method: ['post'],
path: '/account/login',
config: {
tags: ['api'],
description: '登录(手机号码)',
notes: '已完成',
validate: {
payload: joi.object({
// id: joi.number().integer().required()
useraccount: joi.string().required().description("身份证/手机号码"),
pwd: joi.string().required().description("密码")
}),
failAction: FailAction
},
response: {
schema: responseModel
},
},
handler: (req, res) => {
let url = req.headers.referer;
let ttl=24* 60 * 60 * 1000 * 30;
if(url.indexOf("/XXX/") == '-1') {//查看获取的地址中是否有需要的字符串
ttl=10*60*60*1000; //cookie时效:10小时
} else {
ttl=24*60*60*1000*10;//cookie时效:10天
}
res.state('user', account,{ttl:ttl});
}
}
])
}