PC端商户平台node版本登录验证 koa中间件
npm install ft-merchant-ssoshell
mnpm install @dp/ft-merchant-sso --save
`引入
- 需要引入@dp/pigeon-client,并初始化Pigeon和Cat
- 引入@dp/ft-merchant-sso
- app.use(sso());
`javascript
const appName = 'prism-monitor-web'; //项目名称
const Koa = require('koa');
const Pigeon = require("@dp/pigeon-client");
const Cat = require("@dp/cat-client");
const sso = require('@dp/ft-merchant-sso'); //引入sso//应用启动时 初始化Pigeon
Pigeon.init({
appName: appName
});
//如果没有配置过Cat,需要初始化下Cat
Cat.init({
appName: appName
});
let app = new Koa();
app.use(sso());
app.listen(80);
`API 介绍
this指向application
- this.sso.login(redirectUrl) 重定向到登录页,不需要手动调用,页面请求时会自动调用判断是否登录,未登录则跳转至登录页
- this.sso.logout() 登出
- this.sso.accountInfo 获取用户信息
`
{
"shopAccountId":6283703,
"parentId":0,
"contactName":"丽人测试",
"contactMobileNO":"15298390458",
"shopAccount":"6283703",
"accountType":4,
"passwordVersion":161,
"accountName":"lirenceshi001",
"merchantId":976709,
"userType":2,
"interCode":"86",
"email":null,
"password":"",
"password2":"76e48842cd8dde3555623b8b41392781",
"addTime":"2015-10-27T04:01:37.000Z",
"updateTime":"2017-04-01T02:47:27.000Z",
"lastLoginTime":"2017-04-28T03:48:46.000Z"
}
``