generated from VLADIMIR/template_frontend
updates
This commit is contained in:
+33
-2
@@ -132,13 +132,18 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
}
|
||||
|
||||
// Регистрация
|
||||
async function signup(username: string, email: string) {
|
||||
async function signup(
|
||||
username: string,
|
||||
email: string,
|
||||
acceptTerms: boolean,
|
||||
acceptPrivacy: boolean,
|
||||
) {
|
||||
isLoading.value = true
|
||||
error.value = null
|
||||
|
||||
try {
|
||||
const client = buildClient(getToken)
|
||||
const response = await client.Signup({ username, email })
|
||||
const response = await client.Signup({ username, email, acceptTerms, acceptPrivacy })
|
||||
|
||||
if (response.error) {
|
||||
error.value = response.error
|
||||
@@ -154,6 +159,31 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
}
|
||||
}
|
||||
|
||||
// Удаление аккаунта (подтверждение владельца паролем, ст. 21 152-ФЗ)
|
||||
async function deleteAccount(password: string) {
|
||||
isLoading.value = true
|
||||
error.value = null
|
||||
|
||||
try {
|
||||
// Пароль передаётся HTTP-заголовком X-Password, а не в URL или body
|
||||
const client = buildClient(getToken, () => ({ 'X-Password': password }))
|
||||
const response = await client.DeleteAccount({})
|
||||
|
||||
if (response.error) {
|
||||
error.value = response.error
|
||||
return false
|
||||
}
|
||||
|
||||
await logout()
|
||||
return true
|
||||
} catch (err) {
|
||||
error.value = err instanceof Error ? err.message : 'Account deletion failed'
|
||||
return false
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// Восстановление пароля
|
||||
async function refreshPassword(email: string) {
|
||||
isLoading.value = true
|
||||
@@ -216,6 +246,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
getToken,
|
||||
login,
|
||||
signup,
|
||||
deleteAccount,
|
||||
refreshPassword,
|
||||
logout,
|
||||
fetchUser,
|
||||
|
||||
Reference in New Issue
Block a user