mirror of
https://github.com/fumiama/paper-manager.git
synced 2026-06-11 03:20:24 +08:00
login add salt
This commit is contained in:
@@ -67,3 +67,7 @@ export interface GetUserInfoModel {
|
||||
// 介绍
|
||||
desc?: string
|
||||
}
|
||||
|
||||
export interface GetLoginSaltModel {
|
||||
salt: string
|
||||
}
|
||||
|
||||
@@ -7,11 +7,13 @@ import {
|
||||
RegisterParams,
|
||||
ResetPasswordResultModel,
|
||||
RegisterResultModel,
|
||||
GetLoginSaltModel,
|
||||
} from './model/userModel'
|
||||
|
||||
import { ErrorMessageMode } from '/#/axios'
|
||||
|
||||
enum Api {
|
||||
GetLoginSalt = '/getLoginSalt',
|
||||
Login = '/login',
|
||||
Logout = '/logout',
|
||||
ResetPassword = '/resetPassword',
|
||||
@@ -66,6 +68,13 @@ export function registerApi(params: RegisterParams, mode: ErrorMessageMode = 'mo
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: getLoginSalt
|
||||
*/
|
||||
export function getLoginSalt(username: string) {
|
||||
return defHttp.get<GetLoginSaltModel>({ url: Api.GetLoginSalt, params: { username: username } })
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: getUserInfo
|
||||
*/
|
||||
|
||||
@@ -80,6 +80,7 @@
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref, unref, computed } from 'vue'
|
||||
import md5 from 'md5'
|
||||
|
||||
import { Checkbox, Form, Input, Row, Col, Button } from 'ant-design-vue'
|
||||
import LoginFormTitle from './LoginFormTitle.vue'
|
||||
@@ -88,6 +89,7 @@
|
||||
import { useMessage } from '/@/hooks/web/useMessage'
|
||||
|
||||
import { useUserStore } from '/@/store/modules/user'
|
||||
import { getLoginSalt } from '/@/api/sys/user'
|
||||
import { LoginStateEnum, useLoginState, useFormRules, useFormValid } from './useLogin'
|
||||
import { useDesign } from '/@/hooks/web/useDesign'
|
||||
// import { onKeyStroke } from '@vueuse/core'
|
||||
@@ -124,8 +126,9 @@
|
||||
if (!data) return
|
||||
try {
|
||||
loading.value = true
|
||||
const { salt } = await getLoginSalt(data.account)
|
||||
const userInfo = await userStore.login({
|
||||
password: data.password,
|
||||
password: md5(data.password + salt),
|
||||
username: data.account,
|
||||
mode: 'none', //不要默认的错误提示
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user