npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

onenet-passport

v1.0.2

Published

this is a passport plugin for onenet

Downloads

5

Readme

onenet-passport

Build Status Coverage Status MIT Licence

This is a passport plugin for onenet

Install

npm install onenet-passport --save

Usage

const onenetPassport = require('onenet-passport');

1) 用户名唯一性检查

注:用户名可以是username、email、tel等任意类型

onenetPassport.varifyName(userName)

| 参数字段 | 参数名称 | 参数类型 | 是否必须 | 说明 | |----|----|----|----|----| | userName | 用户名 | string | 是 | - |

  • 请求返回
    成功
{"code":0,"msg":"succ"}

失败

{"code":100000,"msg":"用户已存在"}

2) 根据用户名获取用户信息

注:用户名可以是username、email、tel等任意类型

onenetPassport.getUserByName('userName')

| 参数字段 | 参数名称 | 参数类型 | 是否必须 | 说明 | |----|----|----|----|----| | userName | 用户名 | string | 是 | - |

  • 接口返回结果

成功

{"code":0,"msg":"succ","data":{"id":1,"user_type":1,"detail":"[]","error_times":0,"reg_time":"2016-06-15 17:10:45","reg_ip":"192.168.8.12","last_login_time":"2016-06-15 17:12:56","last_login_ip":"192.168.8.12","find_skey":null,"find_time":null}}

失败

{"code":100001,"msg":"用户不存在"}

3) 根据用户ID获取用户信息

注:支持批量拉取用户信息,id之间用英文半角的","分割,最多返回100条数据

onenetPassport.getUserById(id)

| 参数字段 | 参数名称 | 参数类型 | 是否必须 | 说明 | |----|----|----|----|----| | id | 帐号id | string | 是 | - |

  • 接口返回结果

成功

{"code":0,"msg":"succ","data":{"id":1,"user_type":1,"detail":"[]","error_times":0,"reg_time":"2016-06-15 17:10:45","reg_ip":"192.168.8.12","last_login_time":"2016-06-15 17:12:56","last_login_ip":"192.168.8.12","find_skey":null,"find_time":null}}

失败

{"code":100001,"msg":"用户不存在"}

4) 根据用户openId获取用户信息(用于第三方应用获取用户信息)

注:openId在用户登录后即可获得

onenetPassport.getUserById(openId)

| 参数字段 | 参数名称 | 参数类型 | 是否必须 | 说明 | |----|----|----|----|----| | openId | openid | string | 是 | - |

  • 接口返回结果

成功

{"code":0,"msg":"succ","data":{"id":1,"user_type":1,"detail":"[]","error_times":0,"reg_time":"2016-06-15 17:10:45","reg_ip":"192.168.8.12","last_login_time":"2016-06-15 17:12:56","last_login_ip":"192.168.8.12","find_skey":null,"find_time":null}}

失败

{"code":100001,"msg":"用户不存在"}

5) 根据用户名查询用户列表

注:用户名可以是username、email、tel,模糊匹配,最多返回100条数据

onenetPassport.getUserListByName(userName)

| 参数字段 | 参数名称 | 参数类型 | 是否必须 | 说明 | |----|----|----|----|----| | userName | 用户名 | string | 是 | - |

  • 接口返回结果

成功

{"code":0,"msg":"succ","data":{"id":1,"user_type":1,"detail":"[]","error_times":0,"reg_time":"2016-06-15 17:10:45","reg_ip":"192.168.8.12","last_login_time":"2016-06-15 17:12:56","last_login_ip":"192.168.8.12","find_skey":null,"find_time":null}}

失败

{"code":100001,"msg":"用户不存在"}

6) 编辑用户信息

onenetPassport.patch(id, nickname, avatar, detail)

| 参数字段 | 参数名称 | 参数类型 | 是否必须 | 说明 | |----|----|----|----|----| | id | 用户id | int | 是 | - | | nickname | 用户昵称 | string | 否 | - | | avatar | 用户头像 | string | 否 | - | | detail | 用户其他信息 | array | 否 | 注1 | 注1 detail作为数组传入,里边可以包含username、email、tel、nickname、avatar以外的其他参数。

  • 接口返回结果

成功

{"code":0,"msg":"succ","data":{"id":1,"user_type":1,"detail":"[]","error_times":0,"reg_time":"2016-06-15 17:10:45","reg_ip":"192.168.8.12","last_login_time":"2016-06-15 17:12:56","last_login_ip":"192.168.8.12","find_skey":null,"find_time":null}}

失败

{"code":100001,"msg":"用户不存在"}

7) 用户注册

onenetPassport.register(username, userType, regWay, email, tel, password, nickname, avatar)

| 参数字段 | 参数名称 | 参数类型 | 是否必须 | 说明 | |----|----|----|----|----| | username | 用户名 | string | 是 | - | | email | 电子邮箱 | string | 电子邮箱和手机不能同时为空 | - | | tel | 手机号码 | string | 电子邮箱和手机不能同时为空 | - | | password | 密码 | string | 否 | - | | nickname | 昵称 | string | 否 | - | | avatar | 头像 | string | 否 | - | | user_type | 用户类型 | int | 是 | 1:个人用户 2:企业用户 | | reg_way | 注册方式 | int | 是 | 详情参见附件 |

  • 接口返回结果

成功

{"code":0,"msg":"succ","data":{"id":1,"user_type":1,"detail":"[]","error_times":0,"reg_time":"2016-06-15 17:10:45","reg_ip":"192.168.8.12","last_login_time":"2016-06-15 17:12:56","last_login_ip":"192.168.8.12","find_skey":null,"find_time":null}}

失败

{"code":999999,"msg":"注册失败"}

8) 用户登录

注:用户名可以是username、email、tel

onenetPassport.login(username, password, loginIp, loginClient)

| 参数字段 | 参数名称 | 参数类型 | 是否必须 | 说明 | |----|----|----|----|----| | username | 用户名 | string | 是 | - | | password | 密码 | string | 否 | - | | login_ip | 客户端IP | string | 是 | - | | login_client | 客户端类型 | string | 是 | - |

  • 接口返回结果

成功

{"code":0,"msg":"succ","data":{"id":1,"user_type":1,"detail":"[]","error_times":0,"reg_time":"2016-06-15 17:10:45","reg_ip":"192.168.8.12","last_login_time":"2016-06-15 17:12:56","last_login_ip":"192.168.8.12","find_skey":null,"find_time":null}}

失败

{"code":100001,"msg":"用户不存在"}

9) 获取token

@params {Object} configParams 获取token的基本参数与信息

onenetPassport.getToken(configParams)

| 参数字段 | 参数名称 | 参数类型 | 是否必须 | 说明 | |----|----|----|----|----| | configParams.secret | 渠道密钥 | string | 是 | - | | configParams.app_id | 渠道ID | int | 是 | - |

  • 接口返回结果

成功

{"code":0,"msg":"succ","data":{"token":"f237c5541e9a066dff6821495adc8c72","expires":"2016-10-19 11:41:49"}}

失败

{"code":500,"msg":"XXXX"}

10) 修改密码

onenetPassport.changePassword(id, oldpass, password)

| 参数字段 | 参数名称 | 参数类型 | 是否必须 | 说明 | |----|----|----|----|----| | id | 用户id | int | 是 | - | | oldpass | 当前密码 | string | 是 | - | | password | 新密码 | string | 是 | - |

  • 接口返回结果

成功

{"code":0,"msg":"succ","data":NULL}

失败

{"code":500,"msg":"XXXX"}

3、附件1-返回信息列表

| 返回码(code) | 返回信息(msg) | 备注 | | --- | --- | --- | | 0 | 成功 | - | | 100000 | Access Deny | 权限错误 | | 100001 | 参数错误 | 有必填参数未送入 | | 100002 | 用户已存在 | - | | 100003 | 用户不存在 | - | | 100004 | 两次输入的密码不一致 | - | | 100005 | 密码错误 | - | | 100006 | 第三方帐号不支持修改密码 | - | | 999999 | 系统错误 | 数据处理、数据保存出错 |

4、附件2-注册方式列表

| reg_way | name | | --- | --- | | 1 | 手机 | | 2 | 邮箱 | | 3 | 12582 | | 4 | 新浪微博 | | 5 | 腾讯QQ | | 6 | 微信 | | 7 | 百度 | | 8 | 贯众 |