mirror of https://github.com/langgenius/dify.git
feat: add invitation email judgment
This commit is contained in:
parent
7136714cfa
commit
7e48aa6402
|
|
@ -77,6 +77,11 @@ class OAuthCallback(Resource):
|
|||
return {"error": "OAuth process failed"}, 400
|
||||
|
||||
if invite_token:
|
||||
invitation = RegisterService._get_invitation_by_token(token=invite_token)
|
||||
if invitation:
|
||||
invitation_email = invitation.get("email", None)
|
||||
if invitation_email != user_info.email:
|
||||
return redirect(f"{dify_config.CONSOLE_WEB_URL}/signin?message=InvalidToken")
|
||||
return redirect(f"{dify_config.CONSOLE_WEB_URL}/signin/invite-settings?invite_token={invite_token}")
|
||||
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -725,7 +725,9 @@ class RegisterService:
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def _get_invitation_by_token(cls, token: str, workspace_id: str, email: str) -> Optional[dict[str, str]]:
|
||||
def _get_invitation_by_token(
|
||||
cls, token: str, workspace_id: Optional[str] = None, email: Optional[str] = None
|
||||
) -> 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}"
|
||||
|
|
|
|||
Loading…
Reference in New Issue