提交 880f2b80 编写于 作者: C chenruilong

feat(uni-id-co): 新增 外部系统联登接口

上级 bfdc9abf
......@@ -81,6 +81,11 @@ const {
getSupportedLoginType
} = require('./module/dev/index')
const {
externalRegister,
externalLogin
} = require('./module/external')
module.exports = {
async _before () {
// 支持 callFunction 与 URL化
......@@ -189,6 +194,9 @@ module.exports = {
this.response = {}
// 请求鉴权验证
await this.middleware.verifyRequestSign()
// 通用权限校验模块
await this.middleware.accessControl()
},
......@@ -586,5 +594,23 @@ module.exports = {
/**
* 安全网络握手,目前仅处理微信小程序安全网络握手
*/
secureNetworkHandshakeByWeixin
secureNetworkHandshakeByWeixin,
/**
* 设置密码
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#set-pwd
* @returns
*/
setPwd,
/**
* 外部用户注册,将自身系统的用户账号导入uniId,为其创建一个对应uniId的账号(unieid),使得该账号可以使用依赖uniId的系统及功能。
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#external-register
* @returns
*/
externalRegister,
/**
* 外部用户登录,使用unieid即可登录
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#external-login
* @returns
* */
externalLogin
}
module.exports = {
externalRegister: require('./register'),
externalLogin: require('./login')
}
const { preLogin, postLogin } = require('../../lib/utils/login')
module.exports = async function (params = {}) {
const schema = {
unieid: 'username'
}
this.middleware.validate(params, schema)
const {
unieid
} = params
const user = await preLogin.call(this, {
user: {
username: unieid
}
})
const result = await postLogin.call(this, {
user
})
return {
errCode: result.errCode,
newToken: result.newToken,
unieid
}
}
const { preRegister, postRegister } = require('../../lib/utils/register')
module.exports = async function (params = {}) {
const schema = {
unieid: 'username',
nickname: {
required: false,
type: 'nickname'
},
gender: {
required: false,
type: 'number'
},
avatar: {
required: false,
type: 'string'
}
}
this.middleware.validate(params, schema)
const {
unieid,
avatar,
gender,
nickname
} = params
await preRegister.call(this, {
user: {
username: unieid
}
})
const result = await postRegister.call(this, {
user: {
username: unieid,
avatar,
gender,
nickname
}
})
return {
errCode: result.errCode,
newToken: result.newToken,
unieid,
avatar,
gender,
nickname
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册