From 8ae52221afb82437fe1912d0515253ee76d83baf Mon Sep 17 00:00:00 2001 From: chenruilong Date: Fri, 24 Feb 2023 15:21:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(uni-id-co):=20=E6=B3=A8=E5=86=8C=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6=E5=85=81=E8=AE=B8=E9=85=8D=E7=BD=AE=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E8=A7=92=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cloudfunctions/uni-id-co/lib/utils/register.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/register.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/register.js index a500b84..d937610 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/register.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/register.js @@ -129,12 +129,19 @@ async function postRegister (params = {}) { const { autoSetInviteCode, // 注册时自动设置邀请码 - forceInviteCode // 必须有邀请码才允许注册,注意此逻辑不可对admin生效 + forceInviteCode, // 必须有邀请码才允许注册,注意此逻辑不可对admin生效 + userRegisterDefaultRole // 用户注册时配置的默认角色 } = this.config if (autoSetInviteCode) { user.my_invite_code = await getValidInviteCode() } + // 如果用户注册默认角色配置存在且不为空数组 + if (userRegisterDefaultRole && userRegisterDefaultRole.length) { + // 将用户已有的角色和配置的默认角色合并成一个数组,并去重 + user.role = Array.from(new Set([...(user.role || []), ...userRegisterDefaultRole])) + } + const isAdmin = user.role && user.role.includes('admin') if (forceInviteCode && !isAdmin && !inviteCode) { -- GitLab