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
51f23c5d
Unverified
Commit
51f23c5d
authored
Jan 20, 2024
by
Garfield Dai
Committed by
GitHub
Jan 20, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: support re-invite email. (#2107)
parent
1f48e3d4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
14 deletions
+14
-14
members.py
api/controllers/console/workspace/members.py
+6
-11
account_service.py
api/services/account_service.py
+8
-3
No files found.
api/controllers/console/workspace/members.py
View file @
51f23c5d
# -*- coding:utf-8 -*-
from
flask
import
current_app
from
flask_login
import
current_user
from
flask_restful
import
Resource
,
abort
,
fields
,
marshal_with
,
reqparse
import
services
from
controllers.console
import
api
from
controllers.console.setup
import
setup_required
from
controllers.console.wraps
import
account_initialization_required
,
cloud_edition_billing_resource_check
from
extensions.ext_database
import
db
from
flask
import
current_app
from
flask_login
import
current_user
from
flask_restful
import
Resource
,
abort
,
fields
,
marshal
,
marshal_with
,
reqparse
from
libs.helper
import
TimestampField
from
libs.login
import
login_required
from
models.account
import
Account
,
TenantAccountJoin
from
models.account
import
Account
from
services.account_service
import
RegisterService
,
TenantService
account_fields
=
{
...
...
@@ -64,18 +65,12 @@ class MemberInviteEmailApi(Resource):
for
invitee_email
in
invitee_emails
:
try
:
token
=
RegisterService
.
invite_new_member
(
inviter
.
current_tenant
,
invitee_email
,
role
=
invitee_role
,
inviter
=
inviter
)
account
=
db
.
session
.
query
(
Account
,
TenantAccountJoin
.
role
)
.
join
(
TenantAccountJoin
,
Account
.
id
==
TenantAccountJoin
.
account_id
)
.
filter
(
Account
.
email
==
invitee_email
)
.
first
()
account
,
role
=
account
inviter
=
inviter
)
invitation_results
.
append
({
'status'
:
'success'
,
'email'
:
invitee_email
,
'url'
:
f
'{console_web_url}/activate?email={invitee_email}&token={token}'
})
account
=
marshal
(
account
,
account_fields
)
account
[
'role'
]
=
role
except
Exception
as
e
:
invitation_results
.
append
({
'status'
:
'failed'
,
...
...
api/services/account_service.py
View file @
51f23c5d
...
...
@@ -464,16 +464,21 @@ class RegisterService:
account
=
AccountService
.
create_account
(
email
,
name
)
account
.
status
=
AccountStatus
.
PENDING
.
value
db
.
session
.
commit
()
TenantService
.
create_tenant_member
(
tenant
,
account
,
role
)
else
:
TenantService
.
check_member_permission
(
tenant
,
inviter
,
account
,
'add'
)
ta
=
TenantAccountJoin
.
query
.
filter_by
(
tenant_id
=
tenant
.
id
,
account_id
=
account
.
id
)
.
first
()
if
ta
:
raise
AccountAlreadyInTenantError
(
"Account already in tenant."
)
TenantService
.
create_tenant_member
(
tenant
,
account
,
role
)
if
not
ta
:
TenantService
.
create_tenant_member
(
tenant
,
account
,
role
)
# Support resend invitation email when the account is pending status
if
account
.
status
!=
AccountStatus
.
PENDING
.
value
:
raise
AccountAlreadyInTenantError
(
"Account already in tenant."
)
token
=
cls
.
generate_invite_token
(
tenant
,
account
)
...
...
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