mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
feat: add username parameter to getCaptcha function and hash password with MD5 during login
This commit is contained in:
parent
d4bdee1340
commit
68ce998012
|
|
@ -27,6 +27,7 @@
|
|||
"@wecom/jssdk": "^2.3.1",
|
||||
"axios": "^1.8.4",
|
||||
"cropperjs": "^1.6.2",
|
||||
"crypto-js": "^4.2.0",
|
||||
"dingtalk-jsapi": "^3.1.0",
|
||||
"echarts": "^5.6.0",
|
||||
"element-plus": "^2.10.2",
|
||||
|
|
@ -60,6 +61,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@tsconfig/node22": "^22.0.1",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/file-saver": "^2.0.7",
|
||||
"@types/node": "^22.14.0",
|
||||
"@types/nprogress": "^0.2.3",
|
||||
|
|
|
|||
|
|
@ -112,10 +112,11 @@ const ldapLogin: (
|
|||
|
||||
/**
|
||||
* 获取验证码
|
||||
* @param username
|
||||
* @param loading 接口加载器
|
||||
*/
|
||||
const getCaptcha: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => {
|
||||
return get('/captcha', undefined, loading)
|
||||
const getCaptcha: (username?: string, loading?: Ref<boolean>) => Promise<Result<any>> = (username, loading) => {
|
||||
return get('/captcha', {username: username}, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ interface ChatProfile {
|
|||
authentication_type?: 'password' | 'login'
|
||||
// 登录类型
|
||||
login_value?: Array<string>
|
||||
max_attempts?: number
|
||||
}
|
||||
|
||||
interface ChatUserProfile {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { nanoid } from 'nanoid'
|
||||
import {nanoid} from 'nanoid'
|
||||
|
||||
/**
|
||||
* 数字处理
|
||||
*/
|
||||
|
|
@ -7,6 +8,7 @@ export function toThousands(num: any) {
|
|||
return n.replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
|
||||
})
|
||||
}
|
||||
|
||||
export function numberFormat(num: number) {
|
||||
return num < 1000 ? toThousands(num) : toThousands((num / 1000).toFixed(1)) + 'k'
|
||||
}
|
||||
|
|
@ -25,6 +27,7 @@ export function filesize(size: number) {
|
|||
|
||||
// 头像
|
||||
export const defaultIcon = '/${window.MaxKB.prefix}/favicon.ico'
|
||||
|
||||
export function isAppIcon(url: string | undefined) {
|
||||
return url === defaultIcon ? '' : url
|
||||
}
|
||||
|
|
@ -65,6 +68,7 @@ export function getImgUrl(name: string) {
|
|||
: 'unknown'
|
||||
return new URL(`../assets/fileType/${type}-icon.svg`, import.meta.url).href
|
||||
}
|
||||
|
||||
// 是否是白名单后缀
|
||||
export function isRightType(name: string, type: string) {
|
||||
return typeList[type].includes(fileType(name).toLowerCase())
|
||||
|
|
@ -94,7 +98,7 @@ interface LoadScriptOptions {
|
|||
}
|
||||
|
||||
export const loadScript = (url: string, options: LoadScriptOptions = {}): Promise<void> => {
|
||||
const { jsId, forceReload = false } = options
|
||||
const {jsId, forceReload = false} = options
|
||||
const scriptId = jsId || `script-${btoa(url).slice(0, 12)}` // 生成唯一 ID
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
@ -144,12 +148,14 @@ export function getNormalizedUrl(url: string) {
|
|||
}
|
||||
return url
|
||||
}
|
||||
|
||||
export function getFileUrl(fileId?: string) {
|
||||
if (fileId) {
|
||||
return `${window.MaxKB.prefix}/oss/file/${fileId}`
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
export const resetUrl = (url: string, defaultUrl?: string) => {
|
||||
if (url && url.startsWith('./')) {
|
||||
return `${window.MaxKB.prefix}/${url.substring(2)}`
|
||||
|
|
|
|||
|
|
@ -180,6 +180,7 @@ import QrCodeTab from '@/views/chat/user-login/scanCompinents/QrCodeTab.vue'
|
|||
import {MsgConfirm, MsgError} from '@/utils/message.ts'
|
||||
import PasswordAuth from '@/views/chat/auth/component/password.vue'
|
||||
import {isAppIcon} from '@/utils/common'
|
||||
import CryptoJS from "crypto-js";
|
||||
|
||||
useResize()
|
||||
const router = useRouter()
|
||||
|
|
@ -249,6 +250,7 @@ const loginHandle = () => {
|
|||
})
|
||||
})
|
||||
} else {
|
||||
loginForm.value.password = CryptoJS.MD5(loginForm.value.password.trim()).toString(CryptoJS.enc.Hex)
|
||||
chatUser.login(loginForm.value).then((ok) => {
|
||||
router.push({
|
||||
name: 'chat',
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@
|
|||
</login-layout>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import {onMounted, ref, onBeforeMount, computed} from 'vue'
|
||||
import {computed, onBeforeMount, onMounted, ref} from 'vue'
|
||||
import {useRoute, useRouter} from 'vue-router'
|
||||
import type {FormInstance, FormRules} from 'element-plus'
|
||||
import type {LoginRequest} from '@/api/type/login'
|
||||
|
|
@ -134,13 +134,14 @@ import LoginContainer from '@/layout/login-layout/LoginContainer.vue'
|
|||
import LoginLayout from '@/layout/login-layout/LoginLayout.vue'
|
||||
import loginApi from '@/api/user/login'
|
||||
import authApi from '@/api/system-settings/auth-setting'
|
||||
import {t, getBrowserLang} from '@/locales'
|
||||
import {getBrowserLang, t} from '@/locales'
|
||||
import useStore from '@/stores'
|
||||
import {useI18n} from 'vue-i18n'
|
||||
import QrCodeTab from '@/views/login/scanCompinents/QrCodeTab.vue'
|
||||
import {MsgConfirm, MsgError} from '@/utils/message.ts'
|
||||
import * as dd from 'dingtalk-jsapi'
|
||||
import {loadScript} from '@/utils/common'
|
||||
import CryptoJS from 'crypto-js';
|
||||
|
||||
const router = useRouter()
|
||||
const {login, user, theme} = useStore()
|
||||
|
|
@ -199,6 +200,7 @@ const loginHandle = () => {
|
|||
loading.value = false
|
||||
})
|
||||
} else {
|
||||
loginForm.value.password = CryptoJS.MD5(loginForm.value.password.trim()).toString(CryptoJS.enc.Hex)
|
||||
login
|
||||
.asyncLogin(loginForm.value)
|
||||
.then(() => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue