Füge Sichtbarkeitspräferenzen für Mitgliederprofile hinzu: Ermögliche Benutzern, ihre E-Mail, Telefonnummer und Adresse für andere eingeloggte Mitglieder sichtbar zu machen. Aktualisiere die API, um diese Einstellungen zu respektieren und bei der Profildatenrückgabe zu berücksichtigen.
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 47s
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 47s
This commit is contained in:
@@ -31,7 +31,7 @@ export default defineEventHandler(async (event) => {
|
||||
})
|
||||
}
|
||||
|
||||
const users = await readUsers()
|
||||
const users = await readUsers()
|
||||
const userIndex = users.findIndex(u => u.id === decoded.id)
|
||||
|
||||
if (userIndex === -1) {
|
||||
@@ -59,6 +59,16 @@ export default defineEventHandler(async (event) => {
|
||||
user.email = email
|
||||
user.phone = phone || ''
|
||||
|
||||
// Optional visibility preferences (what to show to other logged-in members)
|
||||
// Expected shape: { showEmail: boolean, showPhone: boolean, showAddress: boolean }
|
||||
const visibility = body.visibility || body.visibilityPreferences || null
|
||||
if (visibility && typeof visibility === 'object') {
|
||||
user.visibility = user.visibility || {}
|
||||
if (typeof visibility.showEmail === 'boolean') user.visibility.showEmail = visibility.showEmail
|
||||
if (typeof visibility.showPhone === 'boolean') user.visibility.showPhone = visibility.showPhone
|
||||
if (typeof visibility.showAddress === 'boolean') user.visibility.showAddress = visibility.showAddress
|
||||
}
|
||||
|
||||
// Handle password change
|
||||
if (currentPassword && newPassword) {
|
||||
const isValid = await verifyPassword(currentPassword, user.password)
|
||||
@@ -93,6 +103,7 @@ export default defineEventHandler(async (event) => {
|
||||
email: user.email,
|
||||
name: user.name,
|
||||
phone: user.phone,
|
||||
visibility: user.visibility || {},
|
||||
roles: roles,
|
||||
role: roles[0] || 'mitglied' // Rückwärtskompatibilität
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user