Files
bssapp/ui/src/stores/mePasswordStore.js
2026-02-11 17:46:22 +03:00

39 lines
789 B
JavaScript

// src/stores/mePasswordStore.js
import { defineStore } from 'pinia'
import api from 'src/services/api'
export const useMePasswordStore = defineStore('mePassword', {
state: () => ({
loading: false,
error: null
}),
actions: {
async changePassword (currentPassword, newPassword) {
this.loading = true
this.error = null
try {
// 🔐 Token interceptor ile otomatik
await api.post('/me/password', {
current_password: currentPassword,
new_password: newPassword
})
return true
} catch (e) {
// 🔥 api.js normalize error
this.error =
e?.message ||
'Şifre güncellenemedi'
throw e
} finally {
this.loading = false
}
}
}
})