mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-24 15:36:50 +08:00
### What problem does this PR solve? Add frontend support for third-party login integration: - Used `getLoginChannels` API to fetch available login channels from the server - Used `loginWithChannel` function to initiate login based on the selected channel - Refactored `useLoginWithGithub` hook to `useOAuthCallback` for generalized OAuth callback handling - Updated the login page to dynamically render third-party login buttons based on the fetched channel list - Styled third-party login buttons to improve user experience - Removed unused code snippets > This PR removes the previously hardcoded GitHub login button. Since the functionality only worked when `location.host` was equal to `demo.ragflow.io`, and the authentication logic is now based on `login.ragflow.io`, this change does not affect the existing logic and is considered a non-breaking change --- #### Frontend Screenshot && Backend Configuration  ```yaml # docker/service_conf.yaml.template # ... oauth: github: icon: github display_name: "Github" # ... custom_channel: display_name: "OIDC" # ... custom_channel_2: display_name: "OAuth2" # ... ``` --- - Related pull requests: - #7379 - #7521 - Related issues: - #3495 ### Type of change - [x] New Feature (non-breaking change which adds functionality) - [x] Refactoring - [x] Performance Improvement
150 lines
2.8 KiB
TypeScript
150 lines
2.8 KiB
TypeScript
import api from '@/utils/api';
|
|
import registerServer from '@/utils/register-server';
|
|
import request, { post } from '@/utils/request';
|
|
|
|
const {
|
|
login,
|
|
logout,
|
|
register,
|
|
setting,
|
|
user_info,
|
|
tenant_info,
|
|
factories_list,
|
|
llm_list,
|
|
my_llm,
|
|
set_api_key,
|
|
set_tenant_info,
|
|
add_llm,
|
|
delete_llm,
|
|
deleteFactory,
|
|
getSystemStatus,
|
|
getSystemVersion,
|
|
getSystemTokenList,
|
|
removeSystemToken,
|
|
createSystemToken,
|
|
getSystemConfig,
|
|
setLangfuseConfig,
|
|
} = api;
|
|
|
|
const methods = {
|
|
login: {
|
|
url: login,
|
|
method: 'post',
|
|
},
|
|
logout: {
|
|
url: logout,
|
|
method: 'get',
|
|
},
|
|
register: {
|
|
url: register,
|
|
method: 'post',
|
|
},
|
|
setting: {
|
|
url: setting,
|
|
method: 'post',
|
|
},
|
|
user_info: {
|
|
url: user_info,
|
|
method: 'get',
|
|
},
|
|
get_tenant_info: {
|
|
url: tenant_info,
|
|
method: 'get',
|
|
},
|
|
set_tenant_info: {
|
|
url: set_tenant_info,
|
|
method: 'post',
|
|
},
|
|
factories_list: {
|
|
url: factories_list,
|
|
method: 'get',
|
|
},
|
|
llm_list: {
|
|
url: llm_list,
|
|
method: 'get',
|
|
},
|
|
my_llm: {
|
|
url: my_llm,
|
|
method: 'get',
|
|
},
|
|
set_api_key: {
|
|
url: set_api_key,
|
|
method: 'post',
|
|
},
|
|
add_llm: {
|
|
url: add_llm,
|
|
method: 'post',
|
|
},
|
|
delete_llm: {
|
|
url: delete_llm,
|
|
method: 'post',
|
|
},
|
|
getSystemStatus: {
|
|
url: getSystemStatus,
|
|
method: 'get',
|
|
},
|
|
getSystemVersion: {
|
|
url: getSystemVersion,
|
|
method: 'get',
|
|
},
|
|
deleteFactory: {
|
|
url: deleteFactory,
|
|
method: 'post',
|
|
},
|
|
listToken: {
|
|
url: getSystemTokenList,
|
|
method: 'get',
|
|
},
|
|
createToken: {
|
|
url: createSystemToken,
|
|
method: 'post',
|
|
},
|
|
removeToken: {
|
|
url: removeSystemToken,
|
|
method: 'delete',
|
|
},
|
|
getSystemConfig: {
|
|
url: getSystemConfig,
|
|
method: 'get',
|
|
},
|
|
setLangfuseConfig: {
|
|
url: setLangfuseConfig,
|
|
method: 'put',
|
|
},
|
|
getLangfuseConfig: {
|
|
url: setLangfuseConfig,
|
|
method: 'get',
|
|
},
|
|
deleteLangfuseConfig: {
|
|
url: setLangfuseConfig,
|
|
method: 'delete',
|
|
},
|
|
} as const;
|
|
|
|
const userService = registerServer<keyof typeof methods>(methods, request);
|
|
|
|
export const getLoginChannels = () => request.get(api.login_channels);
|
|
export const loginWithChannel = (channel: string) =>
|
|
(window.location.href = api.login_channel(channel));
|
|
|
|
export const listTenantUser = (tenantId: string) =>
|
|
request.get(api.listTenantUser(tenantId));
|
|
|
|
export const addTenantUser = (tenantId: string, email: string) =>
|
|
post(api.addTenantUser(tenantId), { email });
|
|
|
|
export const deleteTenantUser = ({
|
|
tenantId,
|
|
userId,
|
|
}: {
|
|
tenantId: string;
|
|
userId: string;
|
|
}) => request.delete(api.deleteTenantUser(tenantId, userId));
|
|
|
|
export const listTenant = () => request.get(api.listTenant);
|
|
|
|
export const agreeTenant = (tenantId: string) =>
|
|
request.put(api.agreeTenant(tenantId));
|
|
|
|
export default userService;
|