mirror of
https://github.com/fumiama/paper-manager.git
synced 2026-06-23 12:00:35 +08:00
finish SecureSetting
This commit is contained in:
@@ -14,6 +14,22 @@ export interface ResetPasswordParams {
|
||||
mobile: string
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Set password interface parameters
|
||||
*/
|
||||
export interface SetPasswordParams {
|
||||
token: string
|
||||
password: string
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Set Contact interface parameters
|
||||
*/
|
||||
export interface SetContactParams {
|
||||
token: string
|
||||
contact: string
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Register interface parameters
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,8 @@ import {
|
||||
LoginResultModel,
|
||||
GetUserInfoModel,
|
||||
ResetPasswordParams,
|
||||
SetPasswordParams,
|
||||
SetContactParams,
|
||||
RegisterParams,
|
||||
ResetPasswordResultModel,
|
||||
RegisterResultModel,
|
||||
@@ -17,6 +19,8 @@ enum Api {
|
||||
Login = '/login',
|
||||
Logout = '/logout',
|
||||
ResetPassword = '/resetPassword',
|
||||
SetPassword = '/setPassword',
|
||||
SetContact = '/setContact',
|
||||
Register = '/register',
|
||||
GetUserInfo = '/getUserInfo',
|
||||
GetUsersCount = '/getUsersCount',
|
||||
@@ -54,6 +58,36 @@ export function resetPasswordApi(params: ResetPasswordParams, mode: ErrorMessage
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: set password api, borrowing the ResetPasswordResultModel as they're the same
|
||||
*/
|
||||
export function setPasswordApi(params: SetPasswordParams, mode: ErrorMessageMode = 'modal') {
|
||||
return defHttp.post<ResetPasswordResultModel>(
|
||||
{
|
||||
url: Api.SetPassword,
|
||||
params,
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: set contact api, borrowing the ResetPasswordResultModel as they're the same
|
||||
*/
|
||||
export function setContactApi(params: SetContactParams, mode: ErrorMessageMode = 'modal') {
|
||||
return defHttp.post<ResetPasswordResultModel>(
|
||||
{
|
||||
url: Api.SetContact,
|
||||
params,
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: register api
|
||||
*/
|
||||
@@ -95,7 +129,7 @@ export function getUsersCount() {
|
||||
}*/
|
||||
|
||||
export function doLogout() {
|
||||
return defHttp.get({ url: Api.Logout })
|
||||
return defHttp.get({ url: Api.Logout }, { errorMessageMode: 'none' })
|
||||
}
|
||||
|
||||
/*export function testRetry() {
|
||||
|
||||
@@ -143,9 +143,7 @@ export const useUserStore = defineStore({
|
||||
if (this.getToken) {
|
||||
try {
|
||||
await doLogout()
|
||||
} catch {
|
||||
console.log('注销Token失败')
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
this.setToken(undefined)
|
||||
this.setSessionTimeout(false)
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
import { defineComponent } from 'vue'
|
||||
import { PageWrapper } from '/@/components/Page'
|
||||
import { BasicForm, useForm } from '/@/components/Form'
|
||||
import { setContactApi } from '/@/api/sys/user'
|
||||
import { useMessage } from '/@/hooks/web/useMessage'
|
||||
import md5 from 'md5'
|
||||
|
||||
import { formSchema } from './contact.data'
|
||||
export default defineComponent({
|
||||
@@ -27,16 +30,18 @@
|
||||
schemas: formSchema,
|
||||
})
|
||||
|
||||
const { createMessage } = useMessage()
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate()
|
||||
const { contactOld, contactNew } = values
|
||||
|
||||
// TODO custom api
|
||||
console.log(contactOld, contactNew)
|
||||
// const { router } = useRouter()
|
||||
// router.push(pageEnum.BASE_LOGIN)
|
||||
} catch (error) {}
|
||||
const { msg } = await setContactApi({
|
||||
token: md5(contactOld + contactNew),
|
||||
contact: contactNew,
|
||||
})
|
||||
createMessage.success(msg)
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
return { register, resetFields, handleSubmit }
|
||||
|
||||
@@ -13,12 +13,18 @@
|
||||
import { defineComponent } from 'vue'
|
||||
import { PageWrapper } from '/@/components/Page'
|
||||
import { BasicForm, useForm } from '/@/components/Form'
|
||||
|
||||
import { setPasswordApi } from '/@/api/sys/user'
|
||||
import { useMessage } from '/@/hooks/web/useMessage'
|
||||
import { useUserStore } from '/@/store/modules/user'
|
||||
import { formSchema } from './pwd.data'
|
||||
import md5 from 'md5'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ChangePassword',
|
||||
components: { BasicForm, PageWrapper },
|
||||
setup() {
|
||||
const { createMessage } = useMessage()
|
||||
|
||||
const [register, { validate, resetFields }] = useForm({
|
||||
size: 'large',
|
||||
baseColProps: { span: 24 },
|
||||
@@ -31,12 +37,15 @@
|
||||
try {
|
||||
const values = await validate()
|
||||
const { passwordOld, passwordNew } = values
|
||||
|
||||
// TODO custom api
|
||||
console.log(passwordOld, passwordNew)
|
||||
// const { router } = useRouter()
|
||||
// router.push(pageEnum.BASE_LOGIN)
|
||||
} catch (error) {}
|
||||
const { msg } = await setPasswordApi({
|
||||
token: md5(passwordOld + passwordNew),
|
||||
password: passwordNew,
|
||||
})
|
||||
createMessage.success(msg)
|
||||
useUserStore().logout(true)
|
||||
} catch (error) {
|
||||
createMessage.error((error as unknown as Error).message)
|
||||
}
|
||||
}
|
||||
|
||||
return { register, resetFields, handleSubmit }
|
||||
|
||||
Reference in New Issue
Block a user