feat: change email, export my data, delete account (with data anonymization)

This commit is contained in:
Florian Sylvain committed 2026-10-30 20:19:07 +01:00
1 parent bb191c389a
commit 10a66cd979
123 files changed
+10789 -76

No files matched your search

+11 -3
View File
@@ -41,8 +41,9 @@ type meAccess struct {
type meResponse struct {
publicuser.PublicUser
Author *meAuthor `json:"author"`
Access meAccess `json:"access"`
PendingEmail *string `json:"pending_email"`
Author *meAuthor `json:"author"`
Access meAccess `json:"access"`
}
func toMeAccess(access useCases.Access) meAccess {
@@ -60,6 +61,13 @@ func toMeAuthor(found *author.Author) *meAuthor {
return &meAuthor{Byline: found.Byline(), ArticleCount: found.ArticleCount}
}
func pendingEmailOf(account user.User) *string {
if account.PendingEmail == "" {
return nil
}
return &account.PendingEmail
}
func (h *MeHandler) Me(w http.ResponseWriter, r *http.Request) {
userId, ok := claims.UserId(r)
if !ok {
@@ -89,7 +97,7 @@ func (h *MeHandler) Me(w http.ResponseWriter, r *http.Request) {
return
}
body, err := json.Marshal(meResponse{PublicUser: publicuser.New(loadedUser), Author: toMeAuthor(linked), Access: toMeAccess(access)})
body, err := json.Marshal(meResponse{PublicUser: publicuser.New(loadedUser), PendingEmail: pendingEmailOf(loadedUser), Author: toMeAuthor(linked), Access: toMeAccess(access)})
if err != nil {
http.Error(w, "Internal server error", http.StatusInternalServerError)
return