auth page enhancement
This commit is contained in:
@@ -6,6 +6,7 @@ export interface UserInfo {
|
||||
email: string
|
||||
role: string
|
||||
status: number
|
||||
ext?: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export const useUserStore = defineStore('user', () => {
|
||||
@@ -71,6 +72,21 @@ export const useUserStore = defineStore('user', () => {
|
||||
}
|
||||
}
|
||||
|
||||
async function updateProfile(data: { email?: string; ext?: Record<string, unknown> }) {
|
||||
const result = await api.put<UserInfo>('/api/v1/me/profile', data)
|
||||
setUser(result)
|
||||
return result
|
||||
}
|
||||
|
||||
async function changePassword(data: {
|
||||
old_password: string
|
||||
new_password: string
|
||||
new_password_confirmation: string
|
||||
}) {
|
||||
await api.put('/api/v1/me/password', data)
|
||||
logout()
|
||||
}
|
||||
|
||||
return {
|
||||
token,
|
||||
refreshToken,
|
||||
@@ -82,5 +98,7 @@ export const useUserStore = defineStore('user', () => {
|
||||
setUser,
|
||||
fetchCurrentUser,
|
||||
logout,
|
||||
updateProfile,
|
||||
changePassword,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user