提交 3153e249 编写于 作者: 雪洛's avatar 雪洛

docs: update uni-id

上级 1527d316
...@@ -482,6 +482,8 @@ function hasPermission(token, permission) { ...@@ -482,6 +482,8 @@ function hasPermission(token, permission) {
| avatar | String | 否 | 头像地址 | | avatar | String | 否 | 头像地址 |
| wx_unionid | String | 否 | 微信unionid | | wx_unionid | String | 否 | 微信unionid |
| wx_openid | Object | 否 | 微信各个平台openid。子结构详见下文 | | wx_openid | Object | 否 | 微信各个平台openid。子结构详见下文 |
| qq_unionid | String | 否 | QQ unionid |
| qq_openid | Object | 否 | QQ各个平台openid。子结构详见下文 |
| ali_openid | String | 否 | 支付宝平台openid | | ali_openid | String | 否 | 支付宝平台openid |
| apple_openid | String | 否 | 苹果登录openid | apple_openid | String | 否 | 苹果登录openid
| comment | String | 否 | 备注 | | comment | String | 否 | 备注 |
...@@ -501,7 +503,7 @@ function hasPermission(token, permission) { ...@@ -501,7 +503,7 @@ function hasPermission(token, permission) {
**wx_openid字段定义** **wx_openid字段定义**
> opendb中uni-id-users表1.0.0调整为下面的结构,uni-id-co使用此标准。如何处理旧数据请参考:[自uni-id升级为uni-id-co+uni-id-common](uniCloud/uni-id-summary.md?id=m-to-co) > opendb中uni-id-users表1.0.0调整为下面的结构,uni-id-co使用此标准。如何处理旧数据请参考:[自uni-id升级为uni-id-co+uni-id-common](uniCloud/uni-id-pages.md?id=m-to-co)
| 字段 | 类型 | 必填 | 描述 | | 字段 | 类型 | 必填 | 描述 |
| ------- | ------| ---- | -------- | | ------- | ------| ---- | -------- |
...@@ -510,6 +512,15 @@ function hasPermission(token, permission) { ...@@ -510,6 +512,15 @@ function hasPermission(token, permission) {
| h5 | String| 否 | 微信网页应用openid | | h5 | String| 否 | 微信网页应用openid |
| web | String| 否 | 微信公众号应用openid | | web | String| 否 | 微信公众号应用openid |
**qq_openid字段定义**
> opendb中uni-id-users表1.0.0调整为下面的结构,uni-id-co使用此标准。如何处理旧数据请参考:[自uni-id升级为uni-id-co+uni-id-common](uniCloud/uni-id-pages.md?id=m-to-co)
| 字段 | 类型 | 必填 | 描述 |
| ------- | ------| ---- | -------- |
| app | String| 否 | app平台QQ openid |
| mp | String| 否 | QQ小程序平台openid |
**realNameAuth 扩展字段定义** **realNameAuth 扩展字段定义**
该字段存储实名认证信息,子节点说明如下。 该字段存储实名认证信息,子节点说明如下。
...@@ -528,13 +539,6 @@ function hasPermission(token, permission) { ...@@ -528,13 +539,6 @@ function hasPermission(token, permission) {
| contact_mobile | String | 否 | 联系人手机号码 | | contact_mobile | String | 否 | 联系人手机号码 |
| contact_email | String | 否 | 联系人邮箱 | | contact_email | String | 否 | 联系人邮箱 |
**job 扩展字段定义**
| 字段 | 类型 | 必填 | 描述 |
| ------- | ------ | ---- | -------- |
| company | String | 否 | 公司名称 |
| title | String | 否 | 职位 |
**register_env字段定义** **register_env字段定义**
**注意:该字段是在前端注册用户时记录的前端环境信息。如果是管理员在云端调用uni-id的addUser添加的用户则无此字段** **注意:该字段是在前端注册用户时记录的前端环境信息。如果是管理员在云端调用uni-id的addUser添加的用户则无此字段**
...@@ -780,6 +784,60 @@ uniIdRouter 是一个运行在前端的、对前端页面访问权限路由进 ...@@ -780,6 +784,60 @@ uniIdRouter 是一个运行在前端的、对前端页面访问权限路由进
``` ```
### 云对象响应触发needLogin
云对象抛出uni-id token过期或token无效错误码时,会触发客户端自动跳转配置的登录页面,以下代码为一个简单示例
```js
// todo云对象
const uniIdCommon = require('uni-id-common')
module.exports = {
_before(){
this.uniIdCommon = uniIdCommon.createInstance({
clientInfo: this.getClientInfo()
})
},
addTodo(title) {
const {
errCode,
errMsg,
uid
} = await this.uniIdCommon.checkToken(this.getUniIdToken())
if(errCode) { // uni-id-common的checkToken接口可能返回`uni-id-token-expired`、`uni-id-check-token-failed`错误码,二者均会触发客户端跳转登陆页面
return {
errCode,
errMsg
}
}
// ...
}
}
```
```html
// 客户端add-todo.vue
<template>
<!-- 略 -->
</template>
<script>
export default {
data() {
return {
}
},
onLoad() {},
methods: {
async addTodo(title){
const todo = uniCloud.importObject('todo')
await todo.addTodo(title) // 调用addTodo时云端checkToken如果返回了token错误、token失效的错误码就会自动跳转到配置的登录页面
}
}
}
</script>
<style>
</style>
```
**注意** **注意**
- pages.json内有`uniIdRouter`节点上述逻辑才会生效,自HBuilderX 3.5.0起创建空项目模板会自动配置空的`uniIdRouter`节点 - pages.json内有`uniIdRouter`节点上述逻辑才会生效,自HBuilderX 3.5.0起创建空项目模板会自动配置空的`uniIdRouter`节点
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册