feat: change email, export my data, delete account (with data anonymization)
This commit is contained in:
1 parent
bb191c389a
commit
10a66cd979
123 files changed
+10789
-76
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package author
|
||||
|
||||
import "strconv"
|
||||
|
||||
const DeletedName = "Deleted user"
|
||||
|
||||
const DeletedSlugPrefix = "deleted-user-"
|
||||
|
||||
func DeletedSlug(id uint32) string {
|
||||
return DeletedSlugPrefix + strconv.FormatUint(uint64(id), 10)
|
||||
}
|
||||
|
||||
func DeletedSlugAttempt(id uint32, attempt int) string {
|
||||
if attempt <= 1 {
|
||||
return DeletedSlug(id)
|
||||
}
|
||||
return DeletedSlug(id) + "-" + strconv.Itoa(attempt)
|
||||
}
|
||||
|
||||
func IsReservedSlug(candidate string) bool {
|
||||
return len(candidate) >= len(DeletedSlugPrefix) && candidate[:len(DeletedSlugPrefix)] == DeletedSlugPrefix
|
||||
}
|
||||
|
||||
func avoidReserved(candidate string) string {
|
||||
if IsReservedSlug(candidate) {
|
||||
return FallbackSlug + "-" + candidate
|
||||
}
|
||||
return candidate
|
||||
}
|
||||
@@ -112,7 +112,7 @@ type Page struct {
|
||||
}
|
||||
|
||||
func IsValidSlug(candidate string) bool {
|
||||
return slug.IsValid(candidate)
|
||||
return slug.IsValid(candidate) && !IsReservedSlug(candidate)
|
||||
}
|
||||
|
||||
func IsValidName(name string) bool {
|
||||
@@ -172,9 +172,9 @@ func ValidateLinks(links []SocialLink) error {
|
||||
}
|
||||
|
||||
func GenerateSlug(name string) string {
|
||||
return slug.Generate(name, FallbackSlug)
|
||||
return avoidReserved(slug.Generate(name, FallbackSlug))
|
||||
}
|
||||
|
||||
func SlugWithSuffix(base string, attempt int) string {
|
||||
return slug.WithSuffix(base, attempt)
|
||||
return avoidReserved(slug.WithSuffix(base, attempt))
|
||||
}
|
||||
Reference in new issue
Block a user