Only admin users can see banned accounts on search

face-detect
Noah Petherbridge 2023-09-09 11:16:34 -07:00
parent e4c1142d55
commit de71d65be6
3 changed files with 21 additions and 4 deletions

View File

@ -96,6 +96,7 @@ func Search() http.HandlerFunc {
NotCertified: isCertified == "false",
InnerCircle: isCertified == "circle",
ShyAccounts: isCertified == "shy",
IsBanned: isCertified == "banned",
Friends: friendSearch,
AgeMin: ageMin,
AgeMax: ageMax,

View File

@ -168,6 +168,7 @@ type UserSearch struct {
NotCertified bool
InnerCircle bool
ShyAccounts bool
IsBanned bool
Friends bool
AgeMin int
AgeMax int
@ -267,16 +268,28 @@ func SearchUsers(user *User, search *UserSearch, pager *Pagination) ([]*User, er
placeholders = append(placeholders, "here_for", "%"+search.HereFor+"%")
}
// All user searches will show active accounts only, unless we are admin.
if user.IsAdmin && search.IsBanned {
wheres = append(wheres, "status IN ?")
placeholders = append(placeholders, []string{
UserStatusBanned,
UserStatusDisabled,
})
} else if !user.IsAdmin {
wheres = append(wheres, "status = ?")
placeholders = append(placeholders, UserStatusActive)
}
// Certified filter (including if Shy Accounts are asked for)
if search.Certified {
wheres = append(wheres, "certified = ?", "status = ?")
placeholders = append(placeholders, search.Certified, UserStatusActive)
wheres = append(wheres, "certified = ?")
placeholders = append(placeholders, search.Certified)
}
// Expressly Not Certified filtering
if search.NotCertified {
wheres = append(wheres, "certified = ?", "status = ?")
placeholders = append(placeholders, false, UserStatusActive)
wheres = append(wheres, "certified = ?")
placeholders = append(placeholders, false)
}
if search.InnerCircle {

View File

@ -88,6 +88,9 @@
<option value="shy"{{if eq $Root.Certified "shy"}} selected{{end}}>Shy Accounts</option>
<option value="false"{{if eq $Root.Certified "false"}} selected{{end}}>Non-certified only</option>
<option value="all"{{if eq $Root.Certified "all"}} selected{{end}}>Show all users</option>
{{if .CurrentUser.IsAdmin}}
<option value="banned"{{if eq $Root.Certified "banned"}} selected{{end}}>Banned or disabled</option>
{{end}}
</select>
</div>
</div>