-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[Bug Fix] Invite links email should contain the correct invite id #12130
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e588218
use common helper create_invitation_for_user
ishaan-jaff 4cb52fc
use common util in proxy
ishaan-jaff c69076d
fix create_invitation_for_user
ishaan-jaff 26e6366
refactor base email
ishaan-jaff ee4057f
test_get_invitation_link_creates_new_when_none_exist
ishaan-jaff 4256306
fix code QA checks
ishaan-jaff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from datetime import timedelta | ||
|
||
from fastapi import HTTPException | ||
|
||
import litellm | ||
from litellm.proxy._types import CommonProxyErrors, InvitationNew, UserAPIKeyAuth | ||
|
||
|
||
async def create_invitation_for_user( | ||
data: InvitationNew, | ||
user_api_key_dict: UserAPIKeyAuth, | ||
): | ||
""" | ||
Create an invitation for the user to onboard to LiteLLM Admin UI. | ||
""" | ||
from litellm.proxy.proxy_server import litellm_proxy_admin_name, prisma_client | ||
|
||
if prisma_client is None: | ||
raise HTTPException( | ||
status_code=400, | ||
detail={"error": CommonProxyErrors.db_not_connected_error.value}, | ||
) | ||
|
||
current_time = litellm.utils.get_utc_datetime() | ||
expires_at = current_time + timedelta(days=7) | ||
|
||
try: | ||
response = await prisma_client.db.litellm_invitationlink.create( | ||
data={ | ||
"user_id": data.user_id, | ||
"created_at": current_time, | ||
"expires_at": expires_at, | ||
"created_by": user_api_key_dict.user_id or litellm_proxy_admin_name, | ||
"updated_at": current_time, | ||
"updated_by": user_api_key_dict.user_id or litellm_proxy_admin_name, | ||
} # type: ignore | ||
) | ||
return response | ||
except Exception as e: | ||
if "Foreign key constraint failed on the field" in str(e): | ||
ishaan-jaff marked this conversation as resolved.
Show resolved
Hide resolved
|
||
raise HTTPException( | ||
status_code=400, | ||
detail={ | ||
"error": "User id does not exist in 'LiteLLM_UserTable'. Fix this by creating user via `/user/new`." | ||
}, | ||
) | ||
raise HTTPException(status_code=500, detail={"error": str(e)}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.