提交 98774f75 编写于 作者: DCloud_JSON's avatar DCloud_JSON 提交者: study夏羽

- 更新依赖的的版本为1.0.26

上级 ee031fe9
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
openApp() //创建在h5端全局悬浮引导用户下载app的功能 openApp() //创建在h5端全局悬浮引导用户下载app的功能
// #endif // #endif
import checkIsAgree from '@/pages/uni-agree/utils/uni-agree.js'; import checkIsAgree from '@/pages/uni-agree/utils/uni-agree.js';
import uniIdPageInit from '@/uni_modules/uni-id-pages/init.js';
export default { export default {
globalData: { globalData: {
searchText: '', searchText: '',
...@@ -18,8 +19,10 @@ ...@@ -18,8 +19,10 @@
this.globalData.$i18n = this.$i18n this.globalData.$i18n = this.$i18n
this.globalData.$t = str => this.$t(str) this.globalData.$t = str => this.$t(str)
initApp(); console.log('uni.getPushClientId',uni.getPushClientId);
initApp();
uniIdPageInit()
// #ifdef APP-PLUS // #ifdef APP-PLUS
//checkIsAgree(); APP端暂时先用原生默认生成的。目前,自定义方式启动vue界面时,原生层已经请求了部分权限这并不符合国家的法规 //checkIsAgree(); APP端暂时先用原生默认生成的。目前,自定义方式启动vue界面时,原生层已经请求了部分权限这并不符合国家的法规
......
## 2.0.5(2022-10-19)
- 更新依赖的`uni-id-pages`的版本为1.0.26
## 2.0.4(2022-09-21) ## 2.0.4(2022-09-21)
- 新增 使用uni-id-pages的账号信息的状态管理功能 - 新增 使用uni-id-pages的账号信息的状态管理功能
## 2.0.3(2022-09-20) ## 2.0.3(2022-09-20)
......
...@@ -47,11 +47,11 @@ export default async function() { ...@@ -47,11 +47,11 @@ export default async function() {
methodName, // 云对象的方法名称 methodName, // 云对象的方法名称
params // 参数列表 params // 参数列表
}) { }) {
console.log('interceptObject',{ // console.log('interceptObject',{
objectName, // 云对象名称 // objectName, // 云对象名称
methodName, // 云对象的方法名称 // methodName, // 云对象的方法名称
params // 参数列表 // params // 参数列表
}); // });
if(objectName == "uni-id-co" && (methodName.includes('loginBy') || ['login','registerUser'].includes(methodName) )){ if(objectName == "uni-id-co" && (methodName.includes('loginBy') || ['login','registerUser'].includes(methodName) )){
console.log('执行登录相关云对象'); console.log('执行登录相关云对象');
params[0].inviteCode = await new Promise((callBack) => { params[0].inviteCode = await new Promise((callBack) => {
...@@ -84,7 +84,7 @@ export default async function() { ...@@ -84,7 +84,7 @@ export default async function() {
}) })
// console.log(params); // console.log(params);
} }
console.log(params); // console.log(params);
}, },
success(e) { success(e) {
console.log(e); console.log(e);
...@@ -94,17 +94,17 @@ export default async function() { ...@@ -94,17 +94,17 @@ export default async function() {
}, },
fail(e){ fail(e){
console.error(e); console.error(e);
if (debug) { // if (debug) {
uni.showModal({ // uni.showModal({
content: JSON.stringify(e), // content: JSON.stringify(e),
showCancel: false // showCancel: false
}); // });
}else{ // }else{
uni.showToast({ // uni.showToast({
title: '系统错误请稍后再试', // title: '系统错误请稍后再试',
icon:'error' // icon:'error'
}); // });
} // }
} }
}) })
......
...@@ -40,6 +40,9 @@ ...@@ -40,6 +40,9 @@
"ios": { "ios": {
}, },
"sdkConfigs": { "sdkConfigs": {
"push": {
"unipush": null
}
} }
} }
}, },
......
//这是应用的配置页面,App.vue挂载到getApp().globalData.config //这是应用的配置页面,App.vue挂载到getApp().globalData.config
export default { export default {
//是否打开调试模式
"debug":false,
"h5": { "h5": {
"url": "https://uni-starter.dcloud.net.cn", // 前端网页托管的域名 "url": "https://uni-starter.dcloud.net.cn", // 前端网页托管的域名
// 在h5端全局悬浮引导用户下载app的功能 更多自定义要求在/common/openApp.js中修改 // 在h5端全局悬浮引导用户下载app的功能 更多自定义要求在/common/openApp.js中修改
...@@ -17,7 +15,7 @@ export default { ...@@ -17,7 +15,7 @@ export default {
"mp": { "mp": {
"weixin": { "weixin": {
//微信小程序原始id,微信小程序分享时 //微信小程序原始id,微信小程序分享时
"id": "gh_33446d7f7a26" "id": ""
} }
}, },
//关于应用 //关于应用
......
## 1.1.3(2022-09-22)
- 修复,引入 uni.scss 引入默认主题色报错的问题
## 1.1.2(2022-09-22)
- 增加主题色 primaryColor 配置选项
## 1.1.1(2022-09-19) ## 1.1.1(2022-09-19)
- 修复,输入后回车,change 事件触发两次,[详情](https://ask.dcloud.net.cn/question/152149) - 修复,输入后回车,change 事件触发两次,[详情](https://ask.dcloud.net.cn/question/152149)
## 1.1.0(2022-06-30) ## 1.1.0(2022-06-30)
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<!-- 开启密码时显示小眼睛 --> <!-- 开启密码时显示小眼睛 -->
<uni-icons v-if="isVal" class="content-clear-icon" :class="{'is-textarea-icon':type==='textarea'}" <uni-icons v-if="isVal" class="content-clear-icon" :class="{'is-textarea-icon':type==='textarea'}"
:type="showPassword?'eye-slash-filled':'eye-filled'" :size="22" :type="showPassword?'eye-slash-filled':'eye-filled'" :size="22"
:color="focusShow?'#2979ff':'#c0c4cc'" @click="onEyes"> :color="focusShow ? primaryColor :'#c0c4cc'" @click="onEyes">
</uni-icons> </uni-icons>
</template> </template>
<template v-else-if="suffixIcon"> <template v-else-if="suffixIcon">
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<template v-else> <template v-else>
<uni-icons v-if="clearable && isVal && !disabled && type !== 'textarea'" class="content-clear-icon" <uni-icons v-if="clearable && isVal && !disabled && type !== 'textarea'" class="content-clear-icon"
:class="{'is-textarea-icon':type==='textarea'}" type="clear" :size="clearSize" :class="{'is-textarea-icon':type==='textarea'}" type="clear" :size="clearSize"
:color="msg?'#dd524d':(focusShow?'#2979ff':'#c0c4cc')" @click="onClear"></uni-icons> :color="msg?'#dd524d':(focusShow? primaryColor :'#c0c4cc')" @click="onClear"></uni-icons>
</template> </template>
<slot name="right"></slot> <slot name="right"></slot>
</view> </view>
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
* @property {Number } clearSize 清除图标的大小,单位px(默认15) * @property {Number } clearSize 清除图标的大小,单位px(默认15)
* @property {String} prefixIcon 输入框头部图标 * @property {String} prefixIcon 输入框头部图标
* @property {String} suffixIcon 输入框尾部图标 * @property {String} suffixIcon 输入框尾部图标
* @property {String} primaryColor 设置主题色(默认#2979ff)
* @property {Boolean} trim 是否自动去除两端的空格 * @property {Boolean} trim 是否自动去除两端的空格
* @value both 去除两端空格 * @value both 去除两端空格
* @value left 去除左侧空格 * @value left 去除左侧空格
...@@ -177,6 +178,10 @@ ...@@ -177,6 +178,10 @@
type: Boolean, type: Boolean,
default: true default: true
}, },
primaryColor: {
type: String,
default: '#2979ff'
},
styles: { styles: {
type: Object, type: Object,
default () { default () {
...@@ -244,7 +249,7 @@ ...@@ -244,7 +249,7 @@
}) })
}, },
inputContentStyle() { inputContentStyle() {
const focusColor = this.focusShow ? '#2979ff' : this.styles.borderColor const focusColor = this.focusShow ? this.primaryColor : this.styles.borderColor
const borderColor = this.inputBorder && this.msg ? '#dd524d' : focusColor const borderColor = this.inputBorder && this.msg ? '#dd524d' : focusColor
return obj2strStyle({ return obj2strStyle({
'border-color': borderColor || '#e5e5e5', 'border-color': borderColor || '#e5e5e5',
......
{ {
"id": "uni-easyinput", "id": "uni-easyinput",
"displayName": "uni-easyinput 增强输入框", "displayName": "uni-easyinput 增强输入框",
"version": "1.1.1", "version": "1.1.3",
"description": "Easyinput 组件是对原生input组件的增强", "description": "Easyinput 组件是对原生input组件的增强",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
......
## 1.0.26(2022-10-18)
- 修复 uni-id-pages 导入时异常的Bug
## 1.0.25(2022-10-14)
- uni-id-co 增加 微信授权手机号登录方式 [文档](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#login-by-weixin-mobile)
- uni-id-co 增加 解绑第三方平台账号 [文档](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#unbind-third-account)
- uni-id-co 微信绑定手机号支持通过`getPhoneNumber`事件回调的`code`绑定 [文档](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#bind-mobile-by-mp-weixin)
- 修复 sendSmsCode 接口未在参数内传递 templateId 时 未能从配置文件读取 templateId 的Bug
## 1.0.24(2022-10-08)
- 修复 报uni-id-users表schema内错误的bug
## 1.0.23(2022-10-08)
- 修复 vue3下vite编译发行打包失败
- 修复 某些情况下注册账号,报TypeErroe:Cannot read properties of undefined (reading ’showToast‘)的错误
## 1.0.22(2022-09-23)
- 修复 某些情况下,修改密码报“两次输入密码不一致”的bug
## 1.0.21(2022-09-21) ## 1.0.21(2022-09-21)
- 修复 store.hasLogin的值在某些情况下会出错的bug - 修复 store.hasLogin的值在某些情况下会出错的bug
## 1.0.20(2022-09-21) ## 1.0.20(2022-09-21)
......
...@@ -66,7 +66,7 @@ function getPwdRules(pwdName = 'password', rePwdName = 'password2') { ...@@ -66,7 +66,7 @@ function getPwdRules(pwdName = 'password', rePwdName = 'password2') {
}, },
{ {
validateFunction: function(rule, value, data, callback) { validateFunction: function(rule, value, data, callback) {
if (value != data.password) { if (value != data[pwdName]) {
callback(ERROR.normal.rePwdErr) callback(ERROR.normal.rePwdErr)
} }
return true return true
......
...@@ -37,7 +37,7 @@ export const mutations = { ...@@ -37,7 +37,7 @@ export const mutations = {
} else { } else {
try { try {
let res = await usersTable.where("'_id' == $cloudEnv_uid") let res = await usersTable.where("'_id' == $cloudEnv_uid")
.field('mobile,nickname,user_name,email,avatar_file') .field('mobile,nickname,username,email,avatar_file')
.get() .get()
console.log('fromDbData',res.result.data); console.log('fromDbData',res.result.data);
this.setUserInfo(res.result.data[0]) this.setUserInfo(res.result.data[0])
...@@ -69,7 +69,7 @@ export const mutations = { ...@@ -69,7 +69,7 @@ export const mutations = {
uni.$emit('uni-id-pages-logout') uni.$emit('uni-id-pages-logout')
this.setUserInfo({},{cover:true}) this.setUserInfo({},{cover:true})
}, },
loginSuccess(e){ loginSuccess(e = {}){
const { const {
showToast = true, toastText = '登录成功', autoBack = true, uniIdRedirectUrl = '' showToast = true, toastText = '登录成功', autoBack = true, uniIdRedirectUrl = ''
} = e } = e
...@@ -94,7 +94,7 @@ export const mutations = { ...@@ -94,7 +94,7 @@ export const mutations = {
delta++ delta++
} }
}) })
console.log('判断需要返回几层:', pages, delta); // console.log('判断需要返回几层:', delta);
if (uniIdRedirectUrl) { if (uniIdRedirectUrl) {
return uni.reLaunch({ return uni.reLaunch({
url: uniIdRedirectUrl url: uniIdRedirectUrl
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
console.log('出乎意料的情况,path:' + path); console.log('出乎意料的情况,path:' + path);
} }
}, },
async login_before(type, navigateBack = true) { async login_before(type, navigateBack = true, options = {}) {
console.log(type); console.log(type);
//提示空实现 //提示空实现
if (["qq", if (["qq",
...@@ -300,7 +300,7 @@ ...@@ -300,7 +300,7 @@
let agreementsRef = this.getParentComponent().$refs.agreements let agreementsRef = this.getParentComponent().$refs.agreements
return agreementsRef.popup(() => { return agreementsRef.popup(() => {
console.log(type, navigateBack); console.log(type, navigateBack);
this.login_before(type, navigateBack) this.login_before(type, navigateBack, options)
}) })
} }
...@@ -331,7 +331,6 @@ ...@@ -331,7 +331,6 @@
} }
// #endif // #endif
uni.showLoading({ uni.showLoading({
mask: true mask: true
}) })
...@@ -397,6 +396,13 @@ ...@@ -397,6 +396,13 @@
} }
}) })
} }
if (type === 'weixinMobile') {
return this.login({
phoneCode: options.phoneNumberCode
}, type)
}
uni.login({ uni.login({
"provider": type, "provider": type,
"onlyAuthorize": true, "onlyAuthorize": true,
...@@ -429,7 +435,7 @@ ...@@ -429,7 +435,7 @@
type type
}); });
//toLowerCase //toLowerCase
let action = 'loginBy' + type.trim().toLowerCase().replace(type[0], type[0].toUpperCase()) let action = 'loginBy' + type.trim().replace(type[0], type[0].toUpperCase())
const uniIdCo = uniCloud.importObject("uni-id-co",{ const uniIdCo = uniCloud.importObject("uni-id-co",{
customUI:true customUI:true
}) })
...@@ -441,7 +447,7 @@ ...@@ -441,7 +447,7 @@
}); });
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
//如果是微信小程序端的微信登录,且为首次登录,就弹出获取微信昵称+头像用于绑定资料 //如果是微信小程序端的微信登录,且为首次登录,就弹出获取微信昵称+头像用于绑定资料
if (type == 'weixin' && result.type == "register") { if (['weixin', 'weixinMobile'].includes(type) && result.type == "register") {
mutations.loginSuccess({ mutations.loginSuccess({
...result, ...result,
showToast: false, showToast: false,
......
...@@ -56,6 +56,7 @@ export default async function() { ...@@ -56,6 +56,7 @@ export default async function() {
} }
// #endif // #endif
/* 注释此代码块原因:与uni-starter中的appinit逻辑一致
//3. 绑定clientDB错误事件 //3. 绑定clientDB错误事件
// clientDB对象 // clientDB对象
const db = uniCloud.database() const db = uniCloud.database()
...@@ -72,9 +73,9 @@ export default async function() { ...@@ -72,9 +73,9 @@ export default async function() {
} }
// 解绑clientDB错误事件 // 解绑clientDB错误事件
//db.off('error', onDBError) //db.off('error', onDBError)
*/
//4. 同步客户端push_clientid至uni-id-device表
//4. 同步客户端push_clientid至device表
if (uniCloud.onRefreshToken) { if (uniCloud.onRefreshToken) {
uniCloud.onRefreshToken(() => { uniCloud.onRefreshToken(() => {
console.log('onRefreshToken'); console.log('onRefreshToken');
...@@ -90,7 +91,11 @@ export default async function() { ...@@ -90,7 +91,11 @@ export default async function() {
console.log('getPushClientId', res); console.log('getPushClientId', res);
}, },
fail(e) { fail(e) {
console.log(e) console.error(e,
"uni-id-pages 默认在刷新token(登录、注销、切换用户)后获取push客户端标识同步至uni-id-device表;",
"\n",
"如果你不使用push模块,请注释或删除,路径:/uni-starter/uni_modules/uni-id-pages/init.js 第79-103行代码"
)
} }
}) })
} }
......
{ {
"id": "uni-id-pages", "id": "uni-id-pages",
"displayName": "uni-id-pages", "displayName": "uni-id-pages",
"version": "1.0.21", "version": "1.0.26",
"description": "云端一体简单、统一、可扩展的用户中心页面模版", "description": "云端一体简单、统一、可扩展的用户中心页面模版",
"keywords": [ "keywords": [
"用户管理", "用户管理",
......
...@@ -7,10 +7,11 @@ ...@@ -7,10 +7,11 @@
<!-- 顶部文字 --> <!-- 顶部文字 -->
<text class="title">请选择登录方式</text> <text class="title">请选择登录方式</text>
<!-- 快捷登录框 当url带参数时有效 --> <!-- 快捷登录框 当url带参数时有效 -->
<template v-if="['apple','weixin'].includes(type)"> <template v-if="['apple','weixin', 'weixinMobile'].includes(type)">
<text class="tip">将根据第三方账号服务平台的授权范围获取你的信息</text> <text class="tip">将根据第三方账号服务平台的授权范围获取你的信息</text>
<view class="quickLogin"> <view class="quickLogin">
<image @click="quickLogin" :src="imgSrc" mode="widthFix" class="quickLoginBtn"></image> <image v-if="type !== 'weixinMobile'" @click="quickLogin" :src="imgSrc" mode="widthFix" class="quickLoginBtn"></image>
<button v-else type="primary" open-type="getPhoneNumber" @getphonenumber="quickLogin">微信授权手机号登录</button>
<uni-id-pages-agreements scope="register" ref="agreements"></uni-id-pages-agreements> <uni-id-pages-agreements scope="register" ref="agreements"></uni-id-pages-agreements>
</view> </view>
</template> </template>
...@@ -98,8 +99,16 @@ ...@@ -98,8 +99,16 @@
//#endif //#endif
}, },
methods: { methods: {
quickLogin() { quickLogin(e) {
this.$refs.uniFabLogin.login_before(this.type) let options = {}
if (e.detail?.code) {
options.phoneNumberCode = e.detail.code
}
if (this.type === 'weixinMobile' && !e.detail?.code) return
this.$refs.uniFabLogin.login_before(this.type, true, options)
}, },
toSmsPage() { toSmsPage() {
console.log('toSmsPage',this.agree); console.log('toSmsPage',this.agree);
......
...@@ -53,9 +53,6 @@ ...@@ -53,9 +53,6 @@
mutations mutations
} from '@/uni_modules/uni-id-pages/common/store.js' } from '@/uni_modules/uni-id-pages/common/store.js'
const {
loginSuccess
} = mutations
const uniIdCo = uniCloud.importObject("uni-id-co") const uniIdCo = uniCloud.importObject("uni-id-co")
export default { export default {
mixins: [mixin], mixins: [mixin],
...@@ -118,7 +115,7 @@ ...@@ -118,7 +115,7 @@
submitForm(params) { submitForm(params) {
uniIdCo.registerUser(this.formData).then(e => { uniIdCo.registerUser(this.formData).then(e => {
console.log(e); console.log(e);
loginSuccess() this.loginSuccess(e)
}) })
.catch(e => { .catch(e => {
console.log(e); console.log(e);
......
...@@ -30,11 +30,11 @@ ...@@ -30,11 +30,11 @@
</view> </view>
<view v-if="isShowPhotoBtn" @tap="uploadImage"> <view v-if="isShowPhotoBtn" @tap="uploadImage">
<slot name="photo" v-if="$slots.photo" /> <slot name="photo" v-if="$slots.photo" />
<image v-else src="uni_modules/uni-id-pages/static/limeClipper/photo.svg" /> <image v-else src="./images/photo.svg" />
</view> </view>
<view v-if="isShowRotateBtn" @tap="rotate"> <view v-if="isShowRotateBtn" @tap="rotate">
<slot name="rotate" v-if="$slots.rotate" /> <slot name="rotate" v-if="$slots.rotate" />
<image v-else src="uni_modules/uni-id-pages/static/limeClipper/rotate.svg" data-type="inverse" /> <image v-else src="./images/rotate.svg" data-type="inverse" />
</view> </view>
<view v-if="isShowConfirmBtn" @tap="confirm"> <view v-if="isShowConfirmBtn" @tap="confirm">
<slot name="confirm" v-if="$slots.confirm" /> <slot name="confirm" v-if="$slots.confirm" />
......
...@@ -160,6 +160,41 @@ ...@@ -160,6 +160,41 @@
uni.navigateTo({ uni.navigateTo({
url:"/uni_modules/uni-id-pages/pages/userinfo/deactivate/deactivate" url:"/uni_modules/uni-id-pages/pages/userinfo/deactivate/deactivate"
}) })
},
async bindThirdAccount(provider) {
const uniIdCo = uniCloud.importObject("uni-id-co")
const bindField = {
weixin: 'wx_openid',
alipay: 'ali_openid',
apple: 'apple_openid',
qq: 'qq_openid'
}[provider.toLowerCase()]
if (this.userInfo[bindField]) {
await uniIdCo['unbind' + provider]()
await mutations.updateUserInfo()
} else {
uni.login({
provider: provider.toLowerCase(),
onlyAuthorize: true,
success: async e => {
const res = await uniIdCo['bind' + provider]({
code: e.code
})
if (res.errCode) {
uni.showToast({
title: res.errMsg || '绑定失败'
})
}
await mutations.updateUserInfo()
},
fail: async (err) => {
console.log(err);
uni.hideLoading()
}
})
}
} }
} }
} }
......
...@@ -52,7 +52,11 @@ const LOG_TYPE = { ...@@ -52,7 +52,11 @@ const LOG_TYPE = {
BIND_WEIXIN: 'bind-weixin', BIND_WEIXIN: 'bind-weixin',
BIND_QQ: 'bind-qq', BIND_QQ: 'bind-qq',
BIND_APPLE: 'bind-apple', BIND_APPLE: 'bind-apple',
BIND_ALIPAY: 'bind-alipay' BIND_ALIPAY: 'bind-alipay',
UNBIND_WEIXIN: 'unbind-weixin',
UNBIND_QQ: 'unbind-qq',
UNBIND_ALIPAY: 'unbind-alipay',
UNBIND_APPLE: 'unbind-apple'
} }
const SMS_SCENE = { const SMS_SCENE = {
......
...@@ -30,7 +30,12 @@ const ERROR = { ...@@ -30,7 +30,12 @@ const ERROR = {
SET_INVITE_CODE_FAILED: 'uni-id-set-invite-code-failed', SET_INVITE_CODE_FAILED: 'uni-id-set-invite-code-failed',
INVALID_INVITE_CODE: 'uni-id-invalid-invite-code', INVALID_INVITE_CODE: 'uni-id-invalid-invite-code',
CHANGE_INVITER_FORBIDDEN: 'uni-id-change-inviter-forbidden', CHANGE_INVITER_FORBIDDEN: 'uni-id-change-inviter-forbidden',
BIND_CONFLICT: 'uni-id-bind-conflict' BIND_CONFLICT: 'uni-id-bind-conflict',
UNBIND_FAIL: 'uni-id-unbind-failed',
UNBIND_NOT_SUPPORTED: 'uni-id-unbind-not-supported',
UNBIND_UNIQUE_LOGIN: 'uni-id-unbind-unique-login',
UNBIND_PASSWORD_NOT_EXISTS: 'uni-id-unbind-password-not-exists',
UNBIND_MOBILE_NOT_EXISTS: 'uni-id-unbind-mobile-not-exists'
} }
function isUniIdError (errCode) { function isUniIdError (errCode) {
......
...@@ -171,6 +171,13 @@ function getNonceStr (length = 16) { ...@@ -171,6 +171,13 @@ function getNonceStr (length = 16) {
return str.substring(0, length) return str.substring(0, length)
} }
try {
require('lodash.merge')
} catch (error) {
console.error('uni-id-co缺少依赖,请在uniCloud/cloudfunctions/common/uni-id-co目录执行 npm install 安装依赖')
throw error
}
module.exports = { module.exports = {
getType, getType,
isValidString, isValidString,
......
...@@ -62,5 +62,17 @@ module.exports = { ...@@ -62,5 +62,17 @@ module.exports = {
}, },
getAccountInfo: { getAccountInfo: {
auth: true auth: true
},
unbindWeixin: {
auth: true
},
unbindAlipay: {
auth: true
},
unbindQQ: {
auth: true
},
unbindApple: {
auth: true
} }
} }
...@@ -29,7 +29,8 @@ const { ...@@ -29,7 +29,8 @@ const {
loginByWeixin, loginByWeixin,
loginByAlipay, loginByAlipay,
loginByQQ, loginByQQ,
loginByApple loginByApple,
loginByWeixinMobile
} = require('./module/login/index') } = require('./module/login/index')
const { const {
logout logout
...@@ -41,7 +42,11 @@ const { ...@@ -41,7 +42,11 @@ const {
bindAlipay, bindAlipay,
bindApple, bindApple,
bindQQ, bindQQ,
bindWeixin bindWeixin,
unbindWeixin,
unbindAlipay,
unbindQQ,
unbindApple
} = require('./module/relate/index') } = require('./module/relate/index')
const { const {
updatePwd, updatePwd,
...@@ -74,7 +79,7 @@ const { ...@@ -74,7 +79,7 @@ const {
} = require('./module/dev/index') } = require('./module/dev/index')
module.exports = { module.exports = {
async _before() { async _before () {
const clientInfo = this.getClientInfo() const clientInfo = this.getClientInfo()
/** /**
* 检查clientInfo,无appId和uniPlatform时本云对象无法正常运行 * 检查clientInfo,无appId和uniPlatform时本云对象无法正常运行
...@@ -157,7 +162,7 @@ module.exports = { ...@@ -157,7 +162,7 @@ module.exports = {
// 挂载uni-captcha到this上,方便后续调用 // 挂载uni-captcha到this上,方便后续调用
this.uniCaptcha = uniCaptcha this.uniCaptcha = uniCaptcha
Object.defineProperty(this, 'uniOpenBridge', { Object.defineProperty(this, 'uniOpenBridge', {
get() { get () {
return require('uni-open-bridge-common') return require('uni-open-bridge-common')
} }
}) })
...@@ -181,7 +186,7 @@ module.exports = { ...@@ -181,7 +186,7 @@ module.exports = {
// 通用权限校验模块 // 通用权限校验模块
await this.middleware.accessControl() await this.middleware.accessControl()
}, },
_after(error, result) { _after (error, result) {
if (error) { if (error) {
// 处理中间件内抛出的标准响应对象 // 处理中间件内抛出的标准响应对象
if (error.errCode && getType(error) === 'object') { if (error.errCode && getType(error) === 'object') {
...@@ -217,6 +222,10 @@ module.exports = { ...@@ -217,6 +222,10 @@ module.exports = {
* @param {String} params.nickname 昵称 * @param {String} params.nickname 昵称
* @param {Array} params.authorizedApp 允许登录的AppID列表 * @param {Array} params.authorizedApp 允许登录的AppID列表
* @param {Array} params.role 用户角色列表 * @param {Array} params.role 用户角色列表
* @param {String} params.mobile 手机号
* @param {String} params.email 邮箱
* @param {Array} params.tags 用户标签
* @param {Number} params.status 用户状态
* @returns * @returns
*/ */
addUser, addUser,
...@@ -359,6 +368,7 @@ module.exports = { ...@@ -359,6 +368,7 @@ module.exports = {
* @returns * @returns
*/ */
loginByApple, loginByApple,
loginByWeixinMobile,
/** /**
* 用户退出登录 * 用户退出登录
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#logout * @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#logout
...@@ -541,5 +551,30 @@ module.exports = { ...@@ -541,5 +551,30 @@ module.exports = {
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#get-supported-login-type * @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#get-supported-login-type
* @returns * @returns
*/ */
getSupportedLoginType getSupportedLoginType,
/**
* 解绑微信
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#unbind-weixin
* @returns
*/
unbindWeixin,
/**
* 解绑支付宝
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#unbind-alipay
* @returns
*/
unbindAlipay,
/**
* 解绑QQ
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#unbind-qq
* @returns
*/
unbindQQ,
/**
* 解绑Apple
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#unbind-apple
* @returns
*/
unbindApple
} }
...@@ -12,7 +12,7 @@ const sentence = { ...@@ -12,7 +12,7 @@ const sentence = {
'uni-id-account-audit-failed': 'Account audit failed', 'uni-id-account-audit-failed': 'Account audit failed',
'uni-id-account-closed': 'Account has been closed', 'uni-id-account-closed': 'Account has been closed',
'uni-id-captcha-required': 'Captcha required', 'uni-id-captcha-required': 'Captcha required',
'uni-id-password-error': 'Username or password error', 'uni-id-password-error': 'Password error',
'uni-id-password-error-exceed-limit': 'The number of password errors is excessive', 'uni-id-password-error-exceed-limit': 'The number of password errors is excessive',
'uni-id-invalid-username': 'Invalid username', 'uni-id-invalid-username': 'Invalid username',
'uni-id-invalid-password': 'invalid password', 'uni-id-invalid-password': 'invalid password',
...@@ -35,7 +35,12 @@ const sentence = { ...@@ -35,7 +35,12 @@ const sentence = {
'uni-id-set-invite-code-failed': 'Set invite code failed', 'uni-id-set-invite-code-failed': 'Set invite code failed',
'uni-id-invalid-invite-code': 'Invalid invite code', 'uni-id-invalid-invite-code': 'Invalid invite code',
'uni-id-change-inviter-forbidden': 'Change inviter is not allowed', 'uni-id-change-inviter-forbidden': 'Change inviter is not allowed',
'uni-id-bind-conflict': 'This account has been bound' 'uni-id-bind-conflict': 'This account has been bound',
'uni-id-admin-exist-in-other-apps': 'Administrator is registered in other consoles',
'uni-id-unbind-failed': 'Please bind first and then unbind',
'uni-id-unbind-not-supported': 'Unbinding is not supported',
'uni-id-unbind-mobile-not-exists': 'This is the only way to login at the moment, please bind your phone number and then try to unbind',
'uni-id-unbind-password-not-exists': 'Please set a password first'
} }
module.exports = { module.exports = {
......
...@@ -12,7 +12,7 @@ const sentence = { ...@@ -12,7 +12,7 @@ const sentence = {
'uni-id-account-audit-failed': '此账号审核失败', 'uni-id-account-audit-failed': '此账号审核失败',
'uni-id-account-closed': '此账号已注销', 'uni-id-account-closed': '此账号已注销',
'uni-id-captcha-required': '请输入图形验证码', 'uni-id-captcha-required': '请输入图形验证码',
'uni-id-password-error': '用户名或密码错误', 'uni-id-password-error': '密码错误',
'uni-id-password-error-exceed-limit': '密码错误次数过多,请稍后再试', 'uni-id-password-error-exceed-limit': '密码错误次数过多,请稍后再试',
'uni-id-invalid-username': '用户名不合法', 'uni-id-invalid-username': '用户名不合法',
'uni-id-invalid-password': '密码不合法', 'uni-id-invalid-password': '密码不合法',
...@@ -35,7 +35,12 @@ const sentence = { ...@@ -35,7 +35,12 @@ const sentence = {
'uni-id-set-invite-code-failed': '设置邀请码失败', 'uni-id-set-invite-code-failed': '设置邀请码失败',
'uni-id-invalid-invite-code': '邀请码不可用', 'uni-id-invalid-invite-code': '邀请码不可用',
'uni-id-change-inviter-forbidden': '禁止修改邀请人', 'uni-id-change-inviter-forbidden': '禁止修改邀请人',
'uni-id-bind-conflict': '此账号已被绑定' 'uni-id-bind-conflict': '此账号已被绑定',
'uni-id-admin-exist-in-other-apps': '超级管理员已在其他控制台注册',
'uni-id-unbind-failed': '请先绑定后再解绑',
'uni-id-unbind-not-supported': '不支持解绑',
'uni-id-unbind-mobile-not-exists': '这是当前唯一登录方式,请绑定手机号后再尝试解绑',
'uni-id-unbind-password-not-exists': '请先设置密码在尝试解绑'
} }
module.exports = { module.exports = {
......
...@@ -86,4 +86,26 @@ module.exports = class Auth { ...@@ -86,4 +86,26 @@ module.exports = class Auth {
avatar avatar
} }
} }
async getPhoneNumber (accessToken, code) {
const url = `/wxa/business/getuserphonenumber?access_token=${accessToken}`
const { phoneInfo } = await this._requestWxOpenapi({
name: 'getPhoneNumber',
url,
data: {
code
},
options: {
method: 'POST',
dataAsQueryString: false,
headers: {
'content-type': 'application/json'
}
}
})
return {
purePhoneNumber: phoneInfo.purePhoneNumber
}
}
} }
...@@ -219,7 +219,8 @@ async function postLogin (params = {}) { ...@@ -219,7 +219,8 @@ async function postLogin (params = {}) {
user user
}) })
: {} : {}
) ),
passwordConfirmed: !!user.password
} }
} }
......
...@@ -5,8 +5,15 @@ const { ...@@ -5,8 +5,15 @@ const {
ERROR ERROR
} = require('../../common/error') } = require('../../common/error')
const { const {
userCollection userCollection, dbCmd, USER_IDENTIFIER
} = require('../../common/constants') } = require('../../common/constants')
const {
getUserIdentifier
} = require('../../lib/utils/account')
const {
batchFindObjctValue
} = require('../../common/utils')
const merge = require('lodash.merge') const merge = require('lodash.merge')
/** /**
...@@ -56,7 +63,100 @@ async function postBind ({ ...@@ -56,7 +63,100 @@ async function postBind ({
} }
} }
async function preUnBind ({
uid,
unBindAccount,
logType
}) {
const notUnBind = ['username', 'mobile', 'email']
const userIdentifier = getUserIdentifier(unBindAccount)
const condition = Object.keys(userIdentifier).reduce((res, key) => {
if (userIdentifier[key]) {
if (notUnBind.includes(key)) {
throw {
errCode: ERROR.UNBIND_NOT_SUPPORTED
}
}
res.push({
[key]: userIdentifier[key]
})
}
return res
}, [])
const currentUnBindAccount = Object.keys(userIdentifier).reduce((res, key) => {
if (userIdentifier[key]) {
res.push(key)
}
return res
}, [])
const { data: users } = await userCollection.where(dbCmd.and(
{ _id: uid },
dbCmd.or(condition)
)).get()
if (users.length <= 0) {
await this.middleware.uniIdLog({
data: {
user_id: uid
},
type: logType,
success: false
})
throw {
errCode: ERROR.UNBIND_FAIL
}
}
const [user] = users
const otherAccounts = batchFindObjctValue(user, Object.keys(USER_IDENTIFIER).filter(key => !notUnBind.includes(key) && !currentUnBindAccount.includes(key)))
let hasOtherAccountBind = false
for (const key in otherAccounts) {
if (otherAccounts[key]) {
hasOtherAccountBind = true
break
}
}
// 如果没有其他第三方登录方式
if (!hasOtherAccountBind) {
// 存在用户名或者邮箱但是没有设置过没密码就提示设置密码
if ((user.username || user.email) && !user.password) {
throw {
errCode: ERROR.UNBIND_PASSWORD_NOT_EXISTS
}
}
// 账号任何登录方式都没有就优先绑定手机号
if (!user.mobile) {
throw {
errCode: ERROR.UNBIND_MOBILE_NOT_EXISTS
}
}
}
}
async function postUnBind ({
uid,
unBindAccount,
logType
}) {
await userCollection.doc(uid).update(unBindAccount)
await this.middleware.uniIdLog({
data: {
user_id: uid
},
type: logType
})
return {
errCode: 0
}
}
module.exports = { module.exports = {
preBind, preBind,
postBind postBind,
preUnBind,
postUnBind
} }
...@@ -45,7 +45,7 @@ async function sendSmsCode ({ ...@@ -45,7 +45,7 @@ async function sendSmsCode ({
action = this.t('verify-mobile') action = this.t('verify-mobile')
break break
} }
const sceneConfig = smsConfig.scene || {} const sceneConfig = (smsConfig.scene || {})[scene] || {}
if (!templateId) { if (!templateId) {
templateId = sceneConfig.templateId templateId = sceneConfig.templateId
} }
......
...@@ -177,10 +177,22 @@ async function getWeixinCache ({ ...@@ -177,10 +177,22 @@ async function getWeixinCache ({
}) })
} }
async function getWeixinAccessToken () {
const weixinPlatform = getWeixinPlatform.call(this)
const appId = this.getClientInfo().appId
const cache = await this.uniOpenBridge.getAccessToken({
dcloudAppid: appId,
platform: 'weixin-' + weixinPlatform
})
return cache.access_token
}
module.exports = { module.exports = {
decryptWeixinData, decryptWeixinData,
getWeixinPlatform, getWeixinPlatform,
generateWeixinCache, generateWeixinCache,
getWeixinCache, getWeixinCache,
saveWeixinUserKey saveWeixinUserKey,
getWeixinAccessToken
} }
...@@ -15,5 +15,6 @@ module.exports = { ...@@ -15,5 +15,6 @@ module.exports = {
loginByEmailLink: require('./login-by-email-link'), loginByEmailLink: require('./login-by-email-link'),
loginByEmailCode: require('./login-by-email-code'), loginByEmailCode: require('./login-by-email-code'),
loginByFacebook: require('./login-by-facebook'), loginByFacebook: require('./login-by-facebook'),
loginByGoogle: require('./login-by-google') loginByGoogle: require('./login-by-google'),
loginByWeixinMobile: require('./login-by-weixin-mobile')
} }
const {
initWeixin
} = require('../../lib/third-party/index')
const {
getWeixinPlatform,
getWeixinAccessToken,
generateWeixinCache,
saveWeixinUserKey
} = require('../../lib/utils/weixin')
const {
ERROR
} = require('../../common/error')
const {
preUnifiedLogin,
postUnifiedLogin
} = require('../../lib/utils/unified-login')
const {
LOG_TYPE
} = require('../../common/constants')
const {
preBind,
postBind
} = require('../../lib/utils/relate')
/**
* 微信授权手机号登录
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#login-by-weixin-mobile
* @param {Object} params
* @param {String} params.phoneCode 微信手机号返回的code
* @param {String} params.inviteCode 邀请码
* @returns
*/
module.exports = async function (params = {}) {
const schema = {
phoneCode: 'string',
inviteCode: {
type: 'string',
required: false
}
}
this.middleware.validate(params, schema)
const { phoneCode, inviteCode } = params
const weixinApi = initWeixin.call(this)
let mobile
try {
const accessToken = await getWeixinAccessToken.call(this)
const mobileRes = await weixinApi.getPhoneNumber(accessToken, phoneCode)
mobile = mobileRes.purePhoneNumber
} catch (error) {
console.error(error)
await this.middleware.uniIdLog({
success: false,
type: LOG_TYPE.LOGIN
})
throw {
errCode: ERROR.GET_THIRD_PARTY_ACCOUNT_FAILED
}
}
const { type, user } = await preUnifiedLogin.call(this, {
user: {
mobile
}
})
let extraData = {
mobile_confirmed: 1
}
if (type === 'login') {
// 绑定手机号
if (!user.mobile_confirmed) {
const bindAccount = {
mobile
}
await preBind.call(this, {
uid: user._id,
bindAccount,
logType: LOG_TYPE.BIND_MOBILE
})
await postBind.call(this, {
uid: user._id,
bindAccount,
extraData: {
mobile_confirmed: 1
},
logType: LOG_TYPE.BIND_MOBILE
})
extraData = {
...extraData,
...bindAccount
}
}
}
return postUnifiedLogin.call(this, {
user,
extraData: {
...extraData
},
isThirdParty: false,
type,
inviteCode
})
}
...@@ -37,10 +37,20 @@ module.exports = async function (params = {}) { ...@@ -37,10 +37,20 @@ module.exports = async function (params = {}) {
role: 'admin' role: 'admin'
}).limit(1).get() }).limit(1).get()
if (getAdminRes.data.length > 0) { if (getAdminRes.data.length > 0) {
const [admin] = getAdminRes.data
const appId = this.getClientInfo().appId
if (!admin.dcloud_appid || (admin.dcloud_appid && admin.dcloud_appid.includes(appId))) {
return { return {
errCode: ERROR.ADMIN_EXISTS, errCode: ERROR.ADMIN_EXISTS,
errMsg: this.t('uni-id-admin-exists') errMsg: this.t('uni-id-admin-exists')
} }
} else {
return {
errCode: ERROR.ADMIN_EXISTS,
errMsg: this.t('uni-id-admin-exist-in-other-apps')
}
}
} }
const { const {
user, user,
......
...@@ -47,7 +47,7 @@ module.exports = async function (params = {}) { ...@@ -47,7 +47,7 @@ module.exports = async function (params = {}) {
} = getAlipayAccountResult } = getAlipayAccountResult
const bindAccount = { const bindAccount = {
apple_openid: openid ali_openid: openid
} }
await preBind.call(this, { await preBind.call(this, {
uid, uid,
......
...@@ -7,8 +7,10 @@ const { ...@@ -7,8 +7,10 @@ const {
} = require('../../common/constants') } = require('../../common/constants')
const { const {
decryptWeixinData, decryptWeixinData,
getWeixinCache getWeixinCache, getWeixinAccessToken
} = require('../../lib/utils/weixin') } = require('../../lib/utils/weixin')
const { initWeixin } = require('../../lib/third-party')
const { ERROR } = require('../../common/error')
/** /**
* 通过微信绑定手机号 * 通过微信绑定手机号
...@@ -16,6 +18,7 @@ const { ...@@ -16,6 +18,7 @@ const {
* @param {Object} params * @param {Object} params
* @param {String} params.encryptedData 微信获取手机号返回的加密信息 * @param {String} params.encryptedData 微信获取手机号返回的加密信息
* @param {String} params.iv 微信获取手机号返回的初始向量 * @param {String} params.iv 微信获取手机号返回的初始向量
* @param {String} params.code 微信获取手机号返回的code
* @returns * @returns
*/ */
module.exports = async function (params = {}) { module.exports = async function (params = {}) {
...@@ -26,16 +29,43 @@ module.exports = async function (params = {}) { ...@@ -26,16 +29,43 @@ module.exports = async function (params = {}) {
* 因此此接口不应直接使用客户端login获取的code,只能使用缓存的sessionKey * 因此此接口不应直接使用客户端login获取的code,只能使用缓存的sessionKey
*/ */
const schema = { const schema = {
encryptedData: 'string', encryptedData: {
iv: 'string' required: false,
type: 'string'
},
iv: {
required: false,
type: 'string'
},
code: {
required: false,
type: 'string'
}
} }
const { const {
encryptedData, encryptedData,
iv iv,
code
} = params } = params
this.middleware.validate(params, schema) this.middleware.validate(params, schema)
if ((!encryptedData && !iv) && !code) {
return {
errCode: ERROR.INVALID_PARAM
}
}
const uid = this.authInfo.uid const uid = this.authInfo.uid
let mobile
if (code) {
// 区分客户端类型 小程序还是App
const accessToken = await getWeixinAccessToken.call(this)
const weixinApi = initWeixin.call(this)
const res = await weixinApi.getPhoneNumber(accessToken, code)
mobile = res.purePhoneNumber
} else {
const sessionKey = await getWeixinCache.call(this, { const sessionKey = await getWeixinCache.call(this, {
uid, uid,
key: 'session_key' key: 'session_key'
...@@ -43,14 +73,15 @@ module.exports = async function (params = {}) { ...@@ -43,14 +73,15 @@ module.exports = async function (params = {}) {
if (!sessionKey) { if (!sessionKey) {
throw new Error('Session key not found') throw new Error('Session key not found')
} }
const { const res = decryptWeixinData.call(this, {
purePhoneNumber: mobile
} = decryptWeixinData.call(this, {
encryptedData, encryptedData,
sessionKey, sessionKey,
iv iv
}) })
mobile = res.purePhoneNumber
}
const bindAccount = { const bindAccount = {
mobile mobile
} }
......
...@@ -5,5 +5,9 @@ module.exports = { ...@@ -5,5 +5,9 @@ module.exports = {
bindAlipay: require('./bind-alipay'), bindAlipay: require('./bind-alipay'),
bindApple: require('./bind-apple'), bindApple: require('./bind-apple'),
bindQQ: require('./bind-qq'), bindQQ: require('./bind-qq'),
bindWeixin: require('./bind-weixin') bindWeixin: require('./bind-weixin'),
unbindWeixin: require('./unbind-weixin'),
unbindAlipay: require('./unbind-alipay'),
unbindQQ: require('./unbind-qq'),
unbindApple: require('./unbind-apple')
} }
const {
preUnBind,
postUnBind
} = require('../../lib/utils/relate')
const {
LOG_TYPE, dbCmd
} = require('../../common/constants')
/**
* 解绑支付宝
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#unbind-alipay
* @returns
*/
module.exports = async function () {
const { uid } = this.authInfo
await preUnBind.call(this, {
uid,
unBindAccount: {
ali_openid: dbCmd.exists(true)
},
logType: LOG_TYPE.UNBIND_ALIPAY
})
return await postUnBind.call(this, {
uid,
unBindAccount: {
ali_openid: dbCmd.remove()
},
logType: LOG_TYPE.UNBIND_ALIPAY
})
}
const {
preUnBind,
postUnBind
} = require('../../lib/utils/relate')
const {
LOG_TYPE, dbCmd
} = require('../../common/constants')
/**
* 解绑apple
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#unbind-apple
* @returns
*/
module.exports = async function () {
const { uid } = this.authInfo
await preUnBind.call(this, {
uid,
unBindAccount: {
apple_openid: dbCmd.exists(true)
},
logType: LOG_TYPE.UNBIND_APPLE
})
return await postUnBind.call(this, {
uid,
unBindAccount: {
apple_openid: dbCmd.remove()
},
logType: LOG_TYPE.UNBIND_APPLE
})
}
const {
preUnBind,
postUnBind
} = require('../../lib/utils/relate')
const {
LOG_TYPE, dbCmd
} = require('../../common/constants')
const {
getQQPlatform
} = require('../../lib/utils/qq')
/**
* 解绑QQ
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#unbind-qq
* @returns
*/
module.exports = async function () {
const { uid } = this.authInfo
const { appId } = this.getClientInfo()
const qqPlatform = getQQPlatform.call(this)
await preUnBind.call(this, {
uid,
unBindAccount: {
qq_openid: dbCmd.or([
{
[qqPlatform]: dbCmd.exists(true)
},
{
[`${qqPlatform}_${appId}`]: dbCmd.exists(true)
}
]),
qq_unionid: dbCmd.exists(true)
},
logType: LOG_TYPE.UNBIND_QQ
})
return await postUnBind.call(this, {
uid,
unBindAccount: {
qq_openid: dbCmd.remove(),
qq_unionid: dbCmd.remove()
},
logType: LOG_TYPE.UNBIND_QQ
})
}
const {
preUnBind,
postUnBind
} = require('../../lib/utils/relate')
const {
LOG_TYPE, dbCmd
} = require('../../common/constants')
const {
getWeixinPlatform
} = require('../../lib/utils/weixin')
/**
* 解绑微信
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#unbind-weixin
* @returns
*/
module.exports = async function () {
const { uid } = this.authInfo
const weixinPlatform = getWeixinPlatform.call(this)
await preUnBind.call(this, {
uid,
unBindAccount: {
wx_openid: {
[weixinPlatform]: dbCmd.exists(true)
},
wx_unionid: dbCmd.exists(true)
},
logType: LOG_TYPE.UNBIND_WEIXIN
})
return await postUnBind.call(this, {
uid,
unBindAccount: {
wx_openid: dbCmd.remove(),
wx_unionid: dbCmd.remove()
},
logType: LOG_TYPE.UNBIND_WEIXIN
})
}
{ {
"name": "uni-id-co", "name": "uni-id-co",
"version": "1.0.19", "version": "1.0.26",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"keywords": [], "keywords": [],
...@@ -13,5 +13,7 @@ ...@@ -13,5 +13,7 @@
"uni-id-common": "file:../../../../uni-id-common/uniCloud/cloudfunctions/common/uni-id-common", "uni-id-common": "file:../../../../uni-id-common/uniCloud/cloudfunctions/common/uni-id-common",
"uni-open-bridge-common": "file:../../../../uni-open-bridge-common/uniCloud/cloudfunctions/common/uni-open-bridge-common" "uni-open-bridge-common": "file:../../../../uni-open-bridge-common/uniCloud/cloudfunctions/common/uni-open-bridge-common"
}, },
"extensions": {} "extensions": {
"uni-cloud-sms": {}
}
} }
{ {
"bsonType": "object", "bsonType": "object",
"required": ["username", "password"],
"permission": { "permission": {
"read": true, "read": true,
"create": "'CREATE_UNI_ID_USERS' in auth.permission", "create": "'CREATE_UNI_ID_USERS' in auth.permission",
...@@ -15,28 +14,36 @@ ...@@ -15,28 +14,36 @@
"bsonType": "string", "bsonType": "string",
"description": "支付宝平台openid", "description": "支付宝平台openid",
"permission": { "permission": {
"write": false, "read": "'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"apple_openid": { "apple_openid": {
"bsonType": "string", "bsonType": "string",
"description": "苹果登录openid", "description": "苹果登录openid",
"permission": { "permission": {
"write": false, "read": "'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"avatar": { "avatar": {
"bsonType": "string", "bsonType": "string",
"description": "头像地址", "description": "头像地址",
"title": "头像地址", "title": "头像地址",
"trim": "both" "trim": "both",
"permission": {
"read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"write": "doc._id == auth.uid || 'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
}
}, },
"avatar_file": { "avatar_file": {
"bsonType": "file", "bsonType": "file",
"description": "用file类型方便使用uni-file-picker组件", "description": "用file类型方便使用uni-file-picker组件",
"title": "头像文件" "title": "头像文件",
"permission": {
"read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"write": "doc._id == auth.uid || 'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
}
}, },
"comment": { "comment": {
"bsonType": "string", "bsonType": "string",
...@@ -44,8 +51,8 @@ ...@@ -44,8 +51,8 @@
"title": "备注", "title": "备注",
"trim": "both", "trim": "both",
"permission": { "permission": {
"write": false, "read": "'READ_UNI_ID_USERS' in auth.permission",
"read": false "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"dcloud_appid": { "dcloud_appid": {
...@@ -53,8 +60,8 @@ ...@@ -53,8 +60,8 @@
"description": "允许登录的客户端的appid列表", "description": "允许登录的客户端的appid列表",
"foreignKey": "opendb-app-list.appid", "foreignKey": "opendb-app-list.appid",
"permission": { "permission": {
"write": false, "read": "'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"department_id": { "department_id": {
...@@ -68,8 +75,8 @@ ...@@ -68,8 +75,8 @@
"enumType": "tree", "enumType": "tree",
"title": "部门", "title": "部门",
"permission": { "permission": {
"write": false, "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"email": { "email": {
...@@ -79,8 +86,8 @@ ...@@ -79,8 +86,8 @@
"title": "邮箱", "title": "邮箱",
"trim": "both", "trim": "both",
"permission": { "permission": {
"write": false, "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"email_confirmed": { "email_confirmed": {
...@@ -98,8 +105,8 @@ ...@@ -98,8 +105,8 @@
], ],
"title": "邮箱验证状态", "title": "邮箱验证状态",
"permission": { "permission": {
"write": false, "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"gender": { "gender": {
...@@ -121,16 +128,16 @@ ...@@ -121,16 +128,16 @@
], ],
"title": "性别", "title": "性别",
"permission": { "permission": {
"write": false, "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"invite_time": { "invite_time": {
"bsonType": "timestamp", "bsonType": "timestamp",
"description": "受邀时间", "description": "受邀时间",
"permission": { "permission": {
"write": false, "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"inviter_uid": { "inviter_uid": {
...@@ -138,24 +145,24 @@ ...@@ -138,24 +145,24 @@
"description": "用户全部上级邀请者", "description": "用户全部上级邀请者",
"trim": "both", "trim": "both",
"permission": { "permission": {
"write": false, "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"last_login_date": { "last_login_date": {
"bsonType": "timestamp", "bsonType": "timestamp",
"description": "最后登录时间", "description": "最后登录时间",
"permission": { "permission": {
"write": false, "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"last_login_ip": { "last_login_ip": {
"bsonType": "string", "bsonType": "string",
"description": "最后登录时 IP 地址", "description": "最后登录时 IP 地址",
"permission": { "permission": {
"write": false, "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"mobile": { "mobile": {
...@@ -165,8 +172,8 @@ ...@@ -165,8 +172,8 @@
"title": "手机号码", "title": "手机号码",
"trim": "both", "trim": "both",
"permission": { "permission": {
"write": false, "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"mobile_confirmed": { "mobile_confirmed": {
...@@ -184,49 +191,49 @@ ...@@ -184,49 +191,49 @@
], ],
"title": "手机号验证状态", "title": "手机号验证状态",
"permission": { "permission": {
"write": false, "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"my_invite_code": { "my_invite_code": {
"bsonType": "string", "bsonType": "string",
"description": "用户自身邀请码", "description": "用户自身邀请码",
"permission": { "permission": {
"write": false, "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"nickname": { "nickname": {
"bsonType": "string", "bsonType": "string",
"description": "用户昵称", "description": "用户昵称",
"title": "昵称", "title": "昵称",
"trim": "both" "trim": "both",
"permission": {
"read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"write": "doc._id == auth.uid || 'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
}
}, },
"password": { "password": {
"bsonType": "password", "bsonType": "password",
"description": "密码,加密存储", "description": "密码,加密存储",
"title": "密码", "title": "密码",
"trim": "both", "trim": "both"
"permission": {
"write": false,
"read": false
}
}, },
"password_secret_version": { "password_secret_version": {
"bsonType": "int", "bsonType": "int",
"description": "密码使用的passwordSecret版本", "description": "密码使用的passwordSecret版本",
"title": "passwordSecret", "title": "passwordSecret",
"permission": { "permission": {
"write": false, "read": false,
"read": false "write": false
} }
}, },
"realname_auth": { "realname_auth": {
"bsonType": "object", "bsonType": "object",
"description": "实名认证信息", "description": "实名认证信息",
"permission": { "permission": {
"write": false, "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
}, },
"properties": { "properties": {
"auth_date": { "auth_date": {
...@@ -291,16 +298,22 @@ ...@@ -291,16 +298,22 @@
"bsonType": "timestamp", "bsonType": "timestamp",
"description": "注册时间", "description": "注册时间",
"forceDefaultValue": { "forceDefaultValue": {
"$env": "now", "$env": "now"
"read": "doc._id == auth.uid" },
"permission": {
"read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"register_ip": { "register_ip": {
"bsonType": "string", "bsonType": "string",
"description": "注册时 IP 地址", "description": "注册时 IP 地址",
"forceDefaultValue": { "forceDefaultValue": {
"$env": "clientIP", "$env": "clientIP"
"read": "doc._id == auth.uid" },
"permission": {
"read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"role": { "role": {
...@@ -312,8 +325,8 @@ ...@@ -312,8 +325,8 @@
}, },
"foreignKey": "uni-id-roles.role_id", "foreignKey": "uni-id-roles.role_id",
"permission": { "permission": {
"write": false, "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
}, },
"title": "角色" "title": "角色"
}, },
...@@ -321,8 +334,8 @@ ...@@ -321,8 +334,8 @@
"bsonType": "int", "bsonType": "int",
"description": "用户积分,积分变更记录可参考:uni-id-scores表定义", "description": "用户积分,积分变更记录可参考:uni-id-scores表定义",
"permission": { "permission": {
"write": false, "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"status": { "status": {
...@@ -330,8 +343,8 @@ ...@@ -330,8 +343,8 @@
"defaultValue": 0, "defaultValue": 0,
"description": "用户状态:0 正常 1 禁用 2 审核中 3 审核拒绝", "description": "用户状态:0 正常 1 禁用 2 审核中 3 审核拒绝",
"permission": { "permission": {
"write": false, "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
}, },
"enum": [{ "enum": [{
"text": "正常", "text": "正常",
...@@ -356,7 +369,8 @@ ...@@ -356,7 +369,8 @@
"bsonType": "array", "bsonType": "array",
"description": "用户token", "description": "用户token",
"permission": { "permission": {
"read": "doc._id == auth.uid" "read": "'READ_UNI_ID_USERS' in auth.permission",
"write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"username": { "username": {
...@@ -365,7 +379,8 @@ ...@@ -365,7 +379,8 @@
"title": "用户名", "title": "用户名",
"trim": "both", "trim": "both",
"permission": { "permission": {
"write": false "read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission",
"write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"wx_openid": { "wx_openid": {
...@@ -390,16 +405,16 @@ ...@@ -390,16 +405,16 @@
} }
}, },
"permission": { "permission": {
"write": false, "read": "'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"wx_unionid": { "wx_unionid": {
"bsonType": "string", "bsonType": "string",
"description": "微信unionid", "description": "微信unionid",
"permission": { "permission": {
"write": false, "read": "'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"qq_openid": { "qq_openid": {
...@@ -416,17 +431,26 @@ ...@@ -416,17 +431,26 @@
} }
}, },
"permission": { "permission": {
"write": false, "read": "'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
"qq_unionid": { "qq_unionid": {
"bsonType": "string", "bsonType": "string",
"description": "QQ unionid", "description": "QQ unionid",
"permission": { "permission": {
"write": false, "read": "'READ_UNI_ID_USERS' in auth.permission",
"read": "doc._id == auth.uid" "write": "'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
},
"third_party": {
"bsonType": "object",
"description": "三方平台凭证",
"permission": {
"read": false,
"write": false
} }
} }
},
"required": []
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册