1.0.0-beta • Published 7 years ago

ft-merchant-sso v1.0.0-beta

Weekly downloads
4
License
ISC
Repository
-
Last release
7 years ago

ft-merchant-sso

PC端商户平台node版本登录验证 koa中间件

安装

mnpm install @dp/ft-merchant-sso --save

引入

  • 需要引入@dp/pigeon-client,并初始化Pigeon和Cat
  • 引入@dp/ft-merchant-sso
  • app.use(sso());
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"
    }

  • pigeon-client Pigeon客户端的node实现, 支持tcp+hessian的调用方式
  • mnpm Private npm registry and web for Meituan
1.0.0-beta

7 years ago