mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2026-04-03 08:05:33 +00:00
21 lines
620 B
JavaScript
21 lines
620 B
JavaScript
import { changePasswordMutation } from '~/graphql/Password'
|
|
|
|
export function useChangePassword({ apollo, store, toast, t }) {
|
|
async function changePassword({ oldPassword, password }) {
|
|
try {
|
|
const { data } = await apollo.mutate({
|
|
mutation: changePasswordMutation,
|
|
variables: { oldPassword, password },
|
|
})
|
|
store.commit('auth/SET_TOKEN', data.changePassword)
|
|
toast.success(t('settings.security.change-password.success'))
|
|
return { success: true }
|
|
} catch (err) {
|
|
toast.error(err.message)
|
|
return { success: false }
|
|
}
|
|
}
|
|
|
|
return { changePassword }
|
|
}
|