Class: sso

sso

sso对象
Name Type Description
opts Object 配置属性 格式:{uri:'网络地址'}

Methods

bindMobile(opts, cb)

绑定手机号
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
 code:'验证码(必填)',
 mobile:'手机号(必填)'
}
cb参数格式:
result参数:{
}
err参数:{
   'err': '错误码',
   'msg': '错误信息'
}
验证验证码
Name Type Default Description
opts Object {} optional 参数
cb callback function(err, doc){} optional 回调
Examples
opts参数:{
 key: 键值(必填)
 code: 验证码(必填)
}
cb参数格式:
成功, doc参数:{
 ret: 验证结果
}
失败,doc参数:{
   'err': '错误码',
   'msg': '错误信息'
}

createUser(opts, cb)

创建用户
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
 token: token(可选, 如果不填,自动从localStorage获取),
 passwd: 密码(可选),
 account: 账号(可选),
 mobile: 手机号(可选),
 email: 邮箱(可选),
 nick: 昵称(可选),
 gender: 性别(可选),
 country: 国家(可选),
 province: 省份(可选),
 city: 城市(可选),
 area: 地区(可选),
 birthday: 生日(可选),
 signature: 签名(可选),
 headimgurl: 头像(可选)
}
cb参数格式:
result参数:{
}
err参数:{
   'err': '错误码',
   'msg': '错误信息'
}

findUser(opts, cb)

获取单个用户信息
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
 id: 'id',//(可选)
 account: '账户',//(可选)
 mobile: '手机号'//(可选)
}
cb参数格式:
result参数:{
}
err参数:{
   'err': '错误码',
   'msg': '错误信息'
}
获取用户信息
Name Type Default Description
opts Object {} optional 参数
cb callback function(err, doc){} optional 回调
Examples
opts参数:{
}
cb参数格式:
成功时,doc参数:{
  id: 用户ObjectId,
  uid: 用户id,
  nick: 昵称,
  gender: 性别,
  province: 省份,
  city: 城市,
  headimgurl: 头像地址,
  signature: 签名
}
失败时,doc参数:{
   'err': '错误码',
   'msg': '错误信息'
}

getUsers(opts, cb)

获取用户列表
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
 page: '第几页',
 rows: '一页几行',
 ids:['ObjectId'],
 keyword: '模糊查询关键字',
 fields: {}, //过滤字段
 sort: {} //按什么排序
}
cb参数格式:
result参数:{
 rows:[]
}
err参数:{
   'err': '错误码',
   'msg': '错误信息'
}
获取验证码
Name Type Default Description
opts Object {} optional 参数
cb callback function(err, doc){} optional 回调
Examples
opts参数:{
 key: 键值(必填)
 length: 验证码长度(可选)
 expire: 过期时间,单位秒(可选)
}
cb参数格式:
成功, doc参数:{
 code: 验证码
 expire: 验证码过期时间
}
失败,doc参数:{
   'err': '错误码',
   'msg': '错误信息'
}

isCheckCode(opts, cb)

是否开启效验码
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
 token: '令牌',//(可选)
}
cb参数格式:
result参数:{
 ret:true|false
}
err参数:{
   'err': '错误码',
   'msg': '错误信息'
}

isSignon(opts, cb)

判断是否登录
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
 token: '令牌',//(必填)
}
cb参数格式:
result参数:{
 ret:true|false
}
err参数:{
   'err': '错误码',
   'msg': '错误信息'
}

ranking(opts, cb)

排名
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
 page:'第几页',
 rows:'一页几行',
 sort:'排名规则'
}
sort例子:
sort:{
'record.jb':-1,
'record.cny':-1,
'record.tb':-1,
'record.dbj':-1,
}
注:-1代表降序,1代表升序,可组合
cb参数格式:
result参数:{
 rows:[{}],
 me:'自己排名信息'
}
err参数:{
   'err': '错误码',
   'msg': '错误信息'
}

removeUsers(opts, cb)

移除指定用户
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
 id: ['用户ObjectId'],//(必填)
}
cb参数格式:
result参数:{
}
err参数:{
   'err': '错误码',
   'msg': '错误信息'
}

resetPasswd(opts, cb)

重置密码
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
 key:'手机号(必填)',
 code:'验证码(必填)',
 passwd:'密码(必填)'
}
cb参数格式:
result参数:{
}
err参数:{
   'err': '错误码',
   'msg': '错误信息'
}
登录
Name Type Default Description
opts Object {} optional 参数
cb callback function(err, doc){} optional 回调
Examples
opts参数:{
 id: id(可选),
 account: 账号(可选),
 mobile: 手机号(可选),
 email: 邮箱(可选),
 passwd: 密码(必填),
}
cb参数格式:
成功时, doc参数:{
  id: 用户ObjectId,
  uid: 用户id,
  nick: 昵称,
  gender: 性别,
  province: 省份,
  city: 城市,
  headimgurl: 头像地址,
  signature: 签名
}
失败时, doc参数:{
   'err': '错误码',
   'msg': '错误信息'
}
游客登录
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
}
cb参数格式:
result参数:{
 id: '账号id',
 token: '令牌',
 account: '账号',
 passwd: '密码'
}
err参数:{
   'err': '错误码',
   'msg': '错误信息'
}
退出登录
Name Type Default Description
cb callback function(err,result){} optional 回调
注册用户
Name Type Default Description
opts Object {} optional 参数
cb callback function(err, doc){} optional 回调
Examples
opts参数:{
 account: 账号(可选),
 mobile: 手机号(可选),
 email: 邮箱(可选),
 passwd: 密码(必填),
 nick: 昵称(可选),
 gender: 性别(可选),
 country: 国家(可选),
 province: 省份(可选),
 city: 城市(可选),
 area: 地区(可选),
 birthday: 生日(可选),
 signature: 签名(可选),
 headimgurl: 头像(可选)
}
cb参数格式:
成功时, doc参数:{
  id: 用户ObjectId,
  uid: 用户id,
  nick: 昵称,
  gender: 性别,
  province: 省份,
  city: 城市,
  headimgurl: 头像地址,
  signature: 签名
}
失败时, doc参数:{
   'err': '错误码',
   'msg': '错误信息'
}
更新密码
Name Type Default Description
opts Object {} optional 参数
cb callback function(err, doc){} optional 回调
Examples
opts参数:{
 token: token(可选, 如果不填,自动从localStorage获取),
 newPasswd:'新密码(必填)',
 passwd:'旧密码(必填)'
}
cb参数格式:
成功, doc参数:{
}
失败, doc参数:{
   'err': '错误码',
   'msg': '错误信息'
}
更新用户信息
Name Type Default Description
opts Object {} optional 参数
cb callback function(err, doc){} optional 回调
Examples
opts参数:{
 token: token(可选, 如果不填,自动从localStorage获取),
 account: 账号(可选),
 mobile: 手机号(可选),
 email: 邮箱(可选),
 nick: 昵称(可选),
 gender: 性别(可选),
 country: 国家(可选),
 province: 省份(可选),
 city: 城市(可选),
 area: 地区(可选),
 birthday: 生日(可选),
 signature: 签名(可选),
 headimgurl: 头像(可选)
}
cb参数格式:
成功, doc参数:{
}
失败, doc参数:{
   'err': '错误码',
   'msg': '错误信息'
}

updateUser(opts, cb)

更新用户信息
Name Type Default Description
opts Object {} optional 参数
cb callback function(err, doc){} optional 回调
Examples
opts参数:{
 token: token(可选, 如果不填,自动从localStorage获取),
 userId: 指定用户OjbectId(可选,需要当前操作用户有相应权限)
 account: 账号(可选),
 mobile: 手机号(可选),
 email: 邮箱(可选),
 nick: 昵称(可选),
 gender: 性别(可选),
 country: 国家(可选),
 province: 省份(可选),
 city: 城市(可选),
 area: 地区(可选),
 birthday: 生日(可选),
 signature: 签名(可选),
 headimgurl: 头像(可选)
}
cb参数格式:
成功, doc参数:{
}
失败, doc参数:{
   'err': '错误码',
   'msg': '错误信息'
}

verifyCode(opts, cb)

获取验证码
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
 mobile:'手机号(必填)'
}
cb参数格式:
result参数:{
 time:'验证码过期时间'
}
err参数:{
   'err': '错误码',
   'msg': '错误信息'
}