aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorJakobDev <jakobdev@gmx.de>2023-07-31 03:18:38 +0200
committerGitHub <noreply@github.com>2023-07-31 01:18:38 +0000
commitea385f5d39a286ec36f3735fc7c5211b141f6165 (patch)
tree2c4ec81c6249cb2b2e53065635158c27ad3fa8be /models
parent7dc2e501134c86b3b6ab213779b19e801fd2bbbf (diff)
downloadgitea-ea385f5d39a286ec36f3735fc7c5211b141f6165.tar.gz
gitea-ea385f5d39a286ec36f3735fc7c5211b141f6165.zip
Fix API leaking Usermail if not logged in (#25097)
The API should only return the real Mail of a User, if the caller is logged in. The check do to this don't work. This PR fixes this. This not really a security issue, but can lead to Spam. --------- Co-authored-by: silverwind <me@silverwind.io>
Diffstat (limited to 'models')
-rw-r--r--models/user/user.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/models/user/user.go b/models/user/user.go
index 4b19eda67b..86cf2ad280 100644
--- a/models/user/user.go
+++ b/models/user/user.go
@@ -203,11 +203,16 @@ func UpdateUserTheme(u *User, themeName string) error {
return UpdateUserCols(db.DefaultContext, u, "theme")
}
+// GetPlaceholderEmail returns an noreply email
+func (u *User) GetPlaceholderEmail() string {
+ return fmt.Sprintf("%s@%s", u.LowerName, setting.Service.NoReplyAddress)
+}
+
// GetEmail returns an noreply email, if the user has set to keep his
// email address private, otherwise the primary email address.
func (u *User) GetEmail() string {
if u.KeepEmailPrivate {
- return fmt.Sprintf("%s@%s", u.LowerName, setting.Service.NoReplyAddress)
+ return u.GetPlaceholderEmail()
}
return u.Email
}