1
0
mirror of https://github.com/fumiama/paper-manager.git synced 2026-06-13 05:03:16 +08:00

login add salt

This commit is contained in:
源文雨
2023-03-16 23:27:29 +08:00
parent 57b32e609f
commit 5889f0e30a
5 changed files with 31 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
import { MockMethod } from 'vite-plugin-mock'
import md5 from 'md5'
import { resultError, resultSuccess, getRequestToken, requestParams } from '../_util'
export function createFakeUserList() {
@@ -60,6 +61,14 @@ const fakeCodeList: any = {
'2': ['2000', '4000', '6000'],
}
export default [
{
url: '/api/getLoginSalt',
timeout: 200,
method: 'get',
response: () => {
return resultSuccess({ salt: 'nc8w9f82hfioq2ci9hcwehcq' })
},
},
// mock user login
{
url: '/api/login',
@@ -68,7 +77,9 @@ export default [
response: ({ body }) => {
const { username, password } = body
const checkUser = createFakeUserList().find(
(item) => item.username === username && password === item.password,
(item) =>
item.username === username &&
password === md5(item.password + 'nc8w9f82hfioq2ci9hcwehcq'),
)
if (!checkUser) {
return resultError('Incorrect account or password!')