mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
fix invitation link sign in logic
This commit is contained in:
parent
2c0f2e8fac
commit
30e5308cb3
3 changed files with 13 additions and 14 deletions
|
@ -7588,6 +7588,8 @@ async def onboarding(invite_link: str):
|
|||
- Pass in user_email if set
|
||||
"""
|
||||
global prisma_client, master_key, general_settings
|
||||
from litellm.proxy.management_helpers.ui_session_handler import UISessionHandler
|
||||
|
||||
if master_key is None:
|
||||
raise ProxyException(
|
||||
message="Master Key not set for Proxy. Please set Master Key to use Admin UI. Set `LITELLM_MASTER_KEY` in .env or set general_settings:master_key in config.yaml. https://docs.litellm.ai/docs/proxy/virtual_keys. If set, use `--detailed_debug` to debug issue.",
|
||||
|
@ -7688,11 +7690,9 @@ async def onboarding(invite_link: str):
|
|||
)
|
||||
|
||||
litellm_dashboard_ui += "?token={}&user_email={}".format(jwt_token, user_email)
|
||||
return {
|
||||
"login_url": litellm_dashboard_ui,
|
||||
"token": jwt_token,
|
||||
"user_email": user_email,
|
||||
}
|
||||
return UISessionHandler.generate_authenticated_redirect_response(
|
||||
redirect_url=litellm_dashboard_ui, jwt_token=jwt_token
|
||||
)
|
||||
|
||||
|
||||
@app.post("/onboarding/claim_token", include_in_schema=False)
|
||||
|
|
|
@ -12,6 +12,7 @@ import {
|
|||
Col,
|
||||
} from "@tremor/react";
|
||||
import { RiAlarmWarningLine, RiCheckboxCircleLine } from "@remixicon/react";
|
||||
import { clearTokenCookies, getAuthToken } from "@/utils/cookieUtils";
|
||||
import {
|
||||
invitationClaimCall,
|
||||
userUpdateUserCall,
|
||||
|
@ -20,7 +21,6 @@ import {
|
|||
} from "@/components/networking";
|
||||
import { jwtDecode } from "jwt-decode";
|
||||
import { Form, Button as Button2, message } from "antd";
|
||||
import { getAuthToken } from "@/utils/cookieUtils";
|
||||
|
||||
export default function Onboarding() {
|
||||
const [form] = Form.useForm();
|
||||
|
@ -38,15 +38,18 @@ export default function Onboarding() {
|
|||
if (!inviteID) {
|
||||
return;
|
||||
}
|
||||
clearTokenCookies();
|
||||
getOnboardingCredentials(inviteID).then((data) => {
|
||||
const login_url = data.login_url;
|
||||
console.log("login_url:", login_url);
|
||||
setLoginUrl(login_url);
|
||||
|
||||
const token = data.token;
|
||||
const token = getAuthToken();
|
||||
if (!token) {
|
||||
return;
|
||||
}
|
||||
const decoded = jwtDecode(token) as { [key: string]: any };
|
||||
setJwtToken(token);
|
||||
|
||||
console.log("decoded:", decoded);
|
||||
setAccessToken(decoded.key);
|
||||
|
||||
|
@ -86,11 +89,7 @@ export default function Onboarding() {
|
|||
let litellm_dashboard_ui = "/ui/";
|
||||
const user_id = data.data?.user_id || data.user_id;
|
||||
litellm_dashboard_ui += "?userID=" + user_id;
|
||||
|
||||
// set cookie "token" to jwtToken
|
||||
document.cookie = "token=" + jwtToken;
|
||||
console.log("redirecting to:", litellm_dashboard_ui);
|
||||
|
||||
window.location.href = litellm_dashboard_ui;
|
||||
});
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Helper file for calls being made to proxy
|
||||
*/
|
||||
import { message } from "antd";
|
||||
|
||||
import { clearTokenCookies } from "@/utils/cookieUtils";
|
||||
const isLocal = process.env.NODE_ENV === "development";
|
||||
export const proxyBaseUrl = isLocal ? "http://localhost:4000" : null;
|
||||
if (isLocal != true) {
|
||||
|
@ -50,7 +50,7 @@ const handleError = async (errorData: string) => {
|
|||
message.info("UI Session Expired. Logging out.");
|
||||
lastErrorTime = currentTime;
|
||||
await sleep(3000); // 5 second sleep
|
||||
document.cookie = "token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
||||
clearTokenCookies();
|
||||
window.location.href = baseUrl;
|
||||
}
|
||||
lastErrorTime = currentTime;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue