39 lines
789 B
JavaScript
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
|
|
}
|
|
}
|
|
}
|
|
})
|