feat: 密码用MD5加密
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import CryptoJS from 'crypto-js'
|
||||
|
||||
function getUniversalZoomLevel() {
|
||||
// 现代浏览器方案
|
||||
if (window.visualViewport) {
|
||||
@@ -146,3 +148,12 @@ export async function DownloadImages(list: Array<{ url: string, name?: string }>
|
||||
}
|
||||
typeof onSuccess === "function" && onSuccess(successCount, errCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* MD5加密密码
|
||||
* @param password 原始密码
|
||||
* @returns MD5加密后的密码
|
||||
*/
|
||||
export function encryptPassword(password: string): string {
|
||||
return CryptoJS.MD5(password).toString()
|
||||
}
|
||||
@@ -50,6 +50,7 @@ import { useUserInfoStore } from '@/stores'
|
||||
import { showToast } from 'vant'
|
||||
import { google } from '@/assets/base64'
|
||||
import { fetchRegisterOrLogin } from '@/api/login'
|
||||
import { encryptPassword } from '@/utils/tools'
|
||||
|
||||
const router = useRouter()
|
||||
const userInfoStore = useUserInfoStore()
|
||||
@@ -109,7 +110,8 @@ const handleLogin = async () => {
|
||||
|
||||
isLoading.value = true
|
||||
|
||||
fetchRegisterOrLogin({ ...formData, operationType: 'LOGIN' }).then((response) => {
|
||||
const encryptedPassword = encryptPassword(formData.password)
|
||||
fetchRegisterOrLogin({ ...formData, password: encryptedPassword, operationType: 'LOGIN' }).then((response) => {
|
||||
console.log('登录成功', response)
|
||||
userInfoStore.setToken(response.token)
|
||||
userInfoStore.setUserInfo(response.user)
|
||||
|
||||
@@ -43,6 +43,7 @@ import Verify from './components/Verify.vue'
|
||||
import Password from './components/Password.vue'
|
||||
import { showToast } from 'vant'
|
||||
import { precheckEmail, resetPassword } from '@/api/login'
|
||||
import { encryptPassword } from '@/utils/tools'
|
||||
|
||||
const router = useRouter()
|
||||
const step = ref<'mail' | 'verify' | 'password'>('mail')
|
||||
@@ -92,7 +93,7 @@ const handleCheckVerifyCode = (data: any) => {
|
||||
}
|
||||
|
||||
const handleSuccess = (data: any) => {
|
||||
fromData.value.password = data.password
|
||||
fromData.value.password = encryptPassword(data.password)
|
||||
resetPassword(fromData.value).then((res) => {
|
||||
// console.log('res', res)
|
||||
showToast('the password has been reset')
|
||||
|
||||
@@ -56,6 +56,7 @@ import { useRouter } from 'vue-router'
|
||||
import { showToast } from 'vant'
|
||||
import { google } from '@/assets/base64'
|
||||
import { fetchRegisterOrLogin } from '@/api/login'
|
||||
import { encryptPassword } from '@/utils/tools'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
@@ -121,7 +122,8 @@ const handleConfirm = async () => {
|
||||
|
||||
isLoading.value = true
|
||||
|
||||
fetchRegisterOrLogin({ ...formData, operationType: 'REGISTER' })
|
||||
const encryptedPassword = encryptPassword(formData.password)
|
||||
fetchRegisterOrLogin({ ...formData, password: encryptedPassword, operationType: 'REGISTER' })
|
||||
.then((res) => {
|
||||
console.log('res', res)
|
||||
showToast('register success')
|
||||
|
||||
Reference in New Issue
Block a user