ilk
This commit is contained in:
38
ui/src/stores/mePasswordStore.js
Normal file
38
ui/src/stores/mePasswordStore.js
Normal file
@@ -0,0 +1,38 @@
|
||||
// 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
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user