Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
7076d41b
Unverified
Commit
7076d41b
authored
Jan 28, 2024
by
Benjamin
Committed by
GitHub
Jan 28, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix/invitemailmultilangs (#2257)
Co-authored-by:
crazywoola
<
427733928@qq.com
>
parent
5a6cb699
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
10 deletions
+15
-10
members.py
api/controllers/console/workspace/members.py
+2
-2
account_service.py
api/services/account_service.py
+6
-6
index.tsx
...eader/account-setting/members-page/invite-modal/index.tsx
+7
-2
No files found.
api/controllers/console/workspace/members.py
View file @
7076d41b
...
@@ -56,6 +56,7 @@ class MemberInviteEmailApi(Resource):
...
@@ -56,6 +56,7 @@ class MemberInviteEmailApi(Resource):
invitee_emails
=
args
[
'emails'
]
invitee_emails
=
args
[
'emails'
]
invitee_role
=
args
[
'role'
]
invitee_role
=
args
[
'role'
]
interface_language
=
args
[
'language'
]
if
invitee_role
not
in
[
'admin'
,
'normal'
]:
if
invitee_role
not
in
[
'admin'
,
'normal'
]:
return
{
'code'
:
'invalid-role'
,
'message'
:
'Invalid role'
},
400
return
{
'code'
:
'invalid-role'
,
'message'
:
'Invalid role'
},
400
...
@@ -64,8 +65,7 @@ class MemberInviteEmailApi(Resource):
...
@@ -64,8 +65,7 @@ class MemberInviteEmailApi(Resource):
console_web_url
=
current_app
.
config
.
get
(
"CONSOLE_WEB_URL"
)
console_web_url
=
current_app
.
config
.
get
(
"CONSOLE_WEB_URL"
)
for
invitee_email
in
invitee_emails
:
for
invitee_email
in
invitee_emails
:
try
:
try
:
token
=
RegisterService
.
invite_new_member
(
inviter
.
current_tenant
,
invitee_email
,
role
=
invitee_role
,
token
=
RegisterService
.
invite_new_member
(
inviter
.
current_tenant
,
invitee_email
,
interface_language
,
role
=
invitee_role
,
inviter
=
inviter
)
inviter
=
inviter
)
invitation_results
.
append
({
invitation_results
.
append
({
'status'
:
'success'
,
'status'
:
'success'
,
'email'
:
invitee_email
,
'email'
:
invitee_email
,
...
...
api/services/account_service.py
View file @
7076d41b
...
@@ -138,8 +138,9 @@ class AccountService:
...
@@ -138,8 +138,9 @@ class AccountService:
return
account
return
account
@
staticmethod
@
staticmethod
def
create_account
(
email
:
str
,
name
:
str
,
password
:
str
=
None
,
def
create_account
(
email
:
str
,
name
:
str
,
interface_language
:
str
,
interface_language
:
str
=
languages
[
0
],
interface_theme
:
str
=
'light'
,
password
:
str
=
None
,
interface_theme
:
str
=
'light'
,
timezone
:
str
=
'America/New_York'
,
)
->
Account
:
timezone
:
str
=
'America/New_York'
,
)
->
Account
:
"""create account"""
"""create account"""
account
=
Account
()
account
=
Account
()
...
@@ -429,7 +430,7 @@ class RegisterService:
...
@@ -429,7 +430,7 @@ class RegisterService:
db
.
session
.
begin_nested
()
db
.
session
.
begin_nested
()
"""Register account"""
"""Register account"""
try
:
try
:
account
=
AccountService
.
create_account
(
email
,
name
,
password
)
account
=
AccountService
.
create_account
(
email
,
name
,
interface_language
=
languages
[
0
],
password
=
password
)
account
.
status
=
AccountStatus
.
ACTIVE
.
value
account
.
status
=
AccountStatus
.
ACTIVE
.
value
account
.
initialized_at
=
datetime
.
utcnow
()
account
.
initialized_at
=
datetime
.
utcnow
()
...
@@ -452,15 +453,14 @@ class RegisterService:
...
@@ -452,15 +453,14 @@ class RegisterService:
return
account
return
account
@
classmethod
@
classmethod
def
invite_new_member
(
cls
,
tenant
:
Tenant
,
email
:
str
,
role
:
str
=
'normal'
,
def
invite_new_member
(
cls
,
tenant
:
Tenant
,
email
:
str
,
language
:
str
,
role
:
str
=
'normal'
,
inviter
:
Account
=
None
)
->
str
:
inviter
:
Account
=
None
)
->
str
:
"""Invite new member"""
"""Invite new member"""
account
=
Account
.
query
.
filter_by
(
email
=
email
)
.
first
()
account
=
Account
.
query
.
filter_by
(
email
=
email
)
.
first
()
if
not
account
:
if
not
account
:
TenantService
.
check_member_permission
(
tenant
,
inviter
,
None
,
'add'
)
TenantService
.
check_member_permission
(
tenant
,
inviter
,
None
,
'add'
)
name
=
email
.
split
(
'@'
)[
0
]
name
=
email
.
split
(
'@'
)[
0
]
account
=
AccountService
.
create_account
(
email
,
name
)
account
=
AccountService
.
create_account
(
email
,
name
,
interface_language
=
language
)
account
.
status
=
AccountStatus
.
PENDING
.
value
account
.
status
=
AccountStatus
.
PENDING
.
value
db
.
session
.
commit
()
db
.
session
.
commit
()
...
...
web/app/components/header/account-setting/members-page/invite-modal/index.tsx
View file @
7076d41b
...
@@ -14,6 +14,8 @@ import { inviteMember } from '@/service/common'
...
@@ -14,6 +14,8 @@ import { inviteMember } from '@/service/common'
import
{
emailRegex
}
from
'@/config'
import
{
emailRegex
}
from
'@/config'
import
{
ToastContext
}
from
'@/app/components/base/toast'
import
{
ToastContext
}
from
'@/app/components/base/toast'
import
type
{
InvitationResult
}
from
'@/models/common'
import
type
{
InvitationResult
}
from
'@/models/common'
import
I18n
from
'@/context/i18n'
import
{
getModelRuntimeSupported
}
from
'@/utils/language'
import
'react-multi-email/dist/style.css'
import
'react-multi-email/dist/style.css'
type
IInviteModalProps
=
{
type
IInviteModalProps
=
{
...
@@ -29,6 +31,9 @@ const InviteModal = ({
...
@@ -29,6 +31,9 @@ const InviteModal = ({
const
[
emails
,
setEmails
]
=
useState
<
string
[]
>
([])
const
[
emails
,
setEmails
]
=
useState
<
string
[]
>
([])
const
{
notify
}
=
useContext
(
ToastContext
)
const
{
notify
}
=
useContext
(
ToastContext
)
const
{
locale
}
=
useContext
(
I18n
)
const
language
=
getModelRuntimeSupported
(
locale
)
const
InvitingRoles
=
useMemo
(()
=>
[
const
InvitingRoles
=
useMemo
(()
=>
[
{
{
name
:
'normal'
,
name
:
'normal'
,
...
@@ -42,11 +47,11 @@ const InviteModal = ({
...
@@ -42,11 +47,11 @@ const InviteModal = ({
const
[
role
,
setRole
]
=
useState
(
InvitingRoles
[
0
])
const
[
role
,
setRole
]
=
useState
(
InvitingRoles
[
0
])
const
handleSend
=
useCallback
(
async
()
=>
{
const
handleSend
=
useCallback
(
async
()
=>
{
if
(
emails
.
map
(
email
=>
emailRegex
.
test
(
email
)).
every
(
Boolean
))
{
if
(
emails
.
map
(
(
email
:
string
)
=>
emailRegex
.
test
(
email
)).
every
(
Boolean
))
{
try
{
try
{
const
{
result
,
invitation_results
}
=
await
inviteMember
({
const
{
result
,
invitation_results
}
=
await
inviteMember
({
url
:
'/workspaces/current/members/invite-email'
,
url
:
'/workspaces/current/members/invite-email'
,
body
:
{
emails
,
role
:
role
.
name
},
body
:
{
emails
,
role
:
role
.
name
,
language
},
})
})
if
(
result
===
'success'
)
{
if
(
result
===
'success'
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment