diff --git a/ui/src/api/chat-user/auth-setting.ts b/ui/src/api/chat-user/auth-setting.ts new file mode 100644 index 000000000..f4f0042dc --- /dev/null +++ b/ui/src/api/chat-user/auth-setting.ts @@ -0,0 +1,38 @@ +import {Result} from '@/request/Result' +import {get, post, put} from '@/request/index' +import {type Ref} from 'vue' + +const prefix = '/chat_user/auth' +/** + * 获取认证设置 + */ +const getAuthSetting: (auth_type: string, loading?: Ref) => Promise> = (auth_type, loading) => { + return get(`${prefix}/${auth_type}/detail`, undefined, loading) +} + +/** + * ldap连接测试 + */ +const postAuthSetting: (data: any, loading?: Ref) => Promise> = ( + data, + loading +) => { + return post(`${prefix}/connection`, data, undefined, loading) +} + +/** + * 修改邮箱设置 + */ +const putAuthSetting: (auth_type: string, data: any, loading?: Ref) => Promise> = ( + auth_type, + data, + loading +) => { + return put(`${prefix}/${auth_type}/info`, data, undefined, loading) +} + +export default { + getAuthSetting, + postAuthSetting, + putAuthSetting +} diff --git a/ui/src/api/chat-user/user-login.ts b/ui/src/api/chat-user/user-login.ts new file mode 100644 index 000000000..4076bcc4f --- /dev/null +++ b/ui/src/api/chat-user/user-login.ts @@ -0,0 +1,94 @@ +import {Result} from '@/request/Result.ts' +import {get, post} from '@/request' +import type {LoginRequest} from '@/api/type/login.ts' +import type {Ref} from 'vue' + +/** + * 登录 + * @param request 登录接口请求表单 + * @param loading 接口加载器 + * @returns 认证数据 + */ +const login: (accessToken: string, request: LoginRequest, loading?: Ref) => Promise> = ( + accessToken: string, + request, + loading, +) => { + return post('/chat_user/login/' + accessToken, request, undefined, loading) +} + +const ldapLogin: (accessToken: string, request: LoginRequest, loading?: Ref) => Promise> = ( + accessToken: string, + request, + loading, +) => { + return post('/chat_user/ldap/login/' + accessToken, request, undefined, loading) +} + + +/** + * 获取验证码 + * @param loading 接口加载器 + */ +const getCaptcha: (loading?: Ref) => Promise> = (loading) => { + return get('/user/captcha', undefined, loading) +} + +/** + * 获取登录方式 + */ +const getAuthType: (accessToken: string, loading?: Ref) => Promise> = (accessToken, loading) => { + return get('chat_user/auth/types/' + accessToken, undefined, loading) +} + +/** + * 获取二维码类型 + */ +const getQrType: (loading?: Ref) => Promise> = (loading) => { + return get('qr_type', undefined, loading) +} + +const getQrSource: (loading?: Ref) => Promise> = (loading) => { + return get('qr_type/source', undefined, loading) +} + +const getDingCallback: (code: string, loading?: Ref) => Promise> = ( + code, + loading +) => { + return get('dingtalk', {code}, loading) +} + +const getDingOauth2Callback: (code: string, loading?: Ref) => Promise> = ( + code, + loading +) => { + return get('dingtalk/oauth2', {code}, loading) +} + +const getWecomCallback: (code: string, loading?: Ref) => Promise> = ( + code, + loading +) => { + return get('wecom', {code}, loading) +} +const getLarkCallback: (code: string, loading?: Ref) => Promise> = ( + code, + loading +) => { + return get('lark/oauth2', {code}, loading) +} + + +export default { + login, + getCaptcha, + getAuthType, + getDingCallback, + getQrType, + getWecomCallback, + getDingOauth2Callback, + getLarkCallback, + getQrSource, + ldapLogin +} diff --git a/ui/src/views/chat/user-login/index.vue b/ui/src/views/chat/user-login/index.vue index 93d42cf07..ae0c132f0 100644 --- a/ui/src/views/chat/user-login/index.vue +++ b/ui/src/views/chat/user-login/index.vue @@ -79,7 +79,7 @@
- +