fix linear

pull/22346/head
Yansong Zhang 10 months ago
parent ffcc793060
commit dd9b3b84ff

@ -102,12 +102,14 @@ class NotOwnerError(BaseHTTPException):
description = "You are not the owner of the workspace."
code = 400
class CannotTransferOwnerToSelfError(BaseHTTPException):
error_code = "cannot_transfer_owner_to_self"
description = "You cannot transfer ownership to yourself."
code = 400
class MemberNotInTenantError(BaseHTTPException):
error_code = "member_not_in_tenant"
description = "The member is not in the workspace."
code = 400
code = 400

@ -189,7 +189,6 @@ class SendOwnerTransferEmailApi(Resource):
if current_user.id == str(member_id):
raise CannotTransferOwnerToSelfError()
if args["language"] is not None and args["language"] == "zh-Hans":
language = "zh-Hans"
@ -202,10 +201,11 @@ class SendOwnerTransferEmailApi(Resource):
abort(404)
else:
member_name = member.name
member_account = member
# check the member is in the workspace
if not TenantService.is_member(member, current_user.current_tenant):
if not TenantService.is_member(member_account, current_user.current_tenant):
raise MemberNotInTenantError()
token = AccountService.send_owner_transfer_email(
account=current_user,
email=email,
@ -267,8 +267,8 @@ class OwnerTransfer(Resource):
parser = reqparse.RequestParser()
parser.add_argument("token", type=str, required=True, nullable=False, location="json")
args = parser.parse_args()
# check if the current user is the owner of the workspace
# check if the current user is the owner of the workspace
if not TenantService.is_owner(current_user, current_user.current_tenant):
raise NotOwnerError()
@ -289,8 +289,9 @@ class OwnerTransfer(Resource):
member = db.session.get(Account, str(member_id))
if not member:
abort(404)
if not TenantService.is_member(member, current_user.current_tenant):
else:
member_account = member
if not TenantService.is_member(member_account, current_user.current_tenant):
raise MemberNotInTenantError()
try:

@ -1092,6 +1092,7 @@ class TenantService:
"""Check if the account is a member of the tenant"""
return TenantService.get_user_role(account, tenant) is not None
class RegisterService:
@classmethod
def _get_invitation_token_key(cls, token: str) -> str:

@ -78,28 +78,20 @@ def send_old_owner_transfer_notify_email_task(language: str, to: str, workspace:
system_features = FeatureService.get_system_features()
if system_features.branding.enabled:
template = "without-brand/transfer_workspace_old_owner_notify_template_zh-CN.html"
html_content = render_template(
template, to=to, code=code, WorkspaceName=workspace, NewOwnerEmail=new_owner_email
)
html_content = render_template(template, to=to, WorkspaceName=workspace, NewOwnerEmail=new_owner_email)
mail.send(to=to, subject="工作区所有权已转移", html=html_content)
else:
html_content = render_template(
template, to=to, code=code, WorkspaceName=workspace, NewOwnerEmail=new_owner_email
)
html_content = render_template(template, to=to, WorkspaceName=workspace, NewOwnerEmail=new_owner_email)
mail.send(to=to, subject="工作区所有权已转移", html=html_content)
else:
template = "transfer_workspace_old_owner_notify_template_en-US.html"
system_features = FeatureService.get_system_features()
if system_features.branding.enabled:
template = "without-brand/transfer_workspace_old_owner_notify_template_en-US.html"
html_content = render_template(
template, to=to, code=code, WorkspaceName=workspace, NewOwnerEmail=new_owner_email
)
html_content = render_template(template, to=to, WorkspaceName=workspace, NewOwnerEmail=new_owner_email)
mail.send(to=to, subject="Workspace ownership has been transferred", html=html_content)
else:
html_content = render_template(
template, to=to, code=code, WorkspaceName=workspace, NewOwnerEmail=new_owner_email
)
html_content = render_template(template, to=to, WorkspaceName=workspace, NewOwnerEmail=new_owner_email)
mail.send(to=to, subject="Workspace ownership has been transferred", html=html_content)
end_at = time.perf_counter()
@ -134,20 +126,20 @@ def send_new_owner_transfer_notify_email_task(language: str, to: str, workspace:
system_features = FeatureService.get_system_features()
if system_features.branding.enabled:
template = "without-brand/transfer_workspace_new_owner_notify_template_zh-CN.html"
html_content = render_template(template, to=to, code=code, WorkspaceName=workspace)
html_content = render_template(template, to=to, WorkspaceName=workspace)
mail.send(to=to, subject=f"您现在是 {workspace} 的所有者", html=html_content)
else:
html_content = render_template(template, to=to, code=code, WorkspaceName=workspace)
html_content = render_template(template, to=to, WorkspaceName=workspace)
mail.send(to=to, subject=f"您现在是 {workspace} 的所有者", html=html_content)
else:
template = "transfer_workspace_new_owner_notify_template_en-US.html"
system_features = FeatureService.get_system_features()
if system_features.branding.enabled:
template = "without-brand/transfer_workspace_new_owner_notify_template_en-US.html"
html_content = render_template(template, to=to, code=code, WorkspaceName=workspace)
html_content = render_template(template, to=to, WorkspaceName=workspace)
mail.send(to=to, subject=f"You are now the owner of {workspace}", html=html_content)
else:
html_content = render_template(template, to=to, code=code, WorkspaceName=workspace)
html_content = render_template(template, to=to, WorkspaceName=workspace)
mail.send(to=to, subject=f"You are now the owner of {workspace}", html=html_content)
end_at = time.perf_counter()

Loading…
Cancel
Save