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>
This commit is contained in:
parent
7dc2e50113
commit
ea385f5d39
4 changed files with 24 additions and 9 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue