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

fix: Use correct typehint for return values #1454

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions api/services/account_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import uuid
from datetime import datetime, timedelta
from hashlib import sha256
from typing import Optional
from typing import Optional, Dict, Any

from werkzeug.exceptions import Forbidden, Unauthorized
from flask import session, current_app
Expand All @@ -24,7 +24,8 @@
from models.account import *
from tasks.mail_invite_member_task import send_invite_member_mail_task

def _create_tenant_for_account(account):

def _create_tenant_for_account(account) -> Tenant:
tenant = TenantService.create_tenant(f"{account.name}'s Workspace")

TenantService.create_tenant_member(tenant, account, role='owner')
Expand Down Expand Up @@ -505,7 +506,7 @@ def revoke_token(cls, workspace_id: str, email: str, token: str):
redis_client.delete(cls._get_invitation_token_key(token))

@classmethod
def get_invitation_if_token_valid(cls, workspace_id: str, email: str, token: str) -> Optional[Account]:
def get_invitation_if_token_valid(cls, workspace_id: str, email: str, token: str) -> Optional[Dict[str, Any]]:
invitation_data = cls._get_invitation_by_token(token, workspace_id, email)
if not invitation_data:
return None
Expand Down Expand Up @@ -539,7 +540,7 @@ def get_invitation_if_token_valid(cls, workspace_id: str, email: str, token: str
}

@classmethod
def _get_invitation_by_token(cls, token: str, workspace_id: str, email: str) -> Optional[str]:
def _get_invitation_by_token(cls, token: str, workspace_id: str, email: str) -> Optional[Dict[str, str]]:
if workspace_id is not None and email is not None:
email_hash = sha256(email.encode()).hexdigest()
cache_key = f'member_invite_token:{workspace_id}, {email_hash}:{token}'
Expand Down