Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement forgot password feature #5534

Merged
merged 14 commits into from
Jul 5, 2024
Prev Previous commit
Next Next commit
Revert unintended code formatting outside of feature changes
  • Loading branch information
xielong committed Jul 4, 2024
commit e95d4e67b1c0032c09d733a06bcd76c18bf73a0f
11 changes: 4 additions & 7 deletions api/services/account_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,18 +321,16 @@ def switch_tenant(account: Account, tenant_id: int = None) -> None:
if tenant_id is None:
raise ValueError("Tenant ID must be provided.")

tenant_account_join = db.session.query(TenantAccountJoin).join(Tenant,
TenantAccountJoin.tenant_id == Tenant.id).filter(
tenant_account_join = db.session.query(TenantAccountJoin).join(Tenant, TenantAccountJoin.tenant_id == Tenant.id).filter(
TenantAccountJoin.account_id == account.id,
TenantAccountJoin.tenant_id == tenant_id,
Tenant.status == TenantStatus.NORMAL,
).first()
).first()

if not tenant_account_join:
raise AccountNotLinkTenantError("Tenant not found or account is not a member of the tenant.")
else:
TenantAccountJoin.query.filter(TenantAccountJoin.account_id == account.id,
TenantAccountJoin.tenant_id != tenant_id).update({'current': False})
TenantAccountJoin.query.filter(TenantAccountJoin.account_id == account.id, TenantAccountJoin.tenant_id != tenant_id).update({'current': False})
tenant_account_join.current = True
# Set the current tenant for the account
account.current_tenant_id = tenant_account_join.tenant_id
Expand Down Expand Up @@ -544,8 +542,7 @@ def register(cls, email, name,
return account

@classmethod
def invite_new_member(cls, tenant: Tenant, email: str, language: str, role: str = 'normal',
inviter: Account = None) -> str:
def invite_new_member(cls, tenant: Tenant, email: str, language: str, role: str = 'normal', inviter: Account = None) -> str:
"""Invite new member"""
account = Account.query.filter_by(email=email).first()

Expand Down