Only admin users can see banned accounts on search
This commit is contained in:
parent
e4c1142d55
commit
de71d65be6
|
@ -96,6 +96,7 @@ func Search() http.HandlerFunc {
|
||||||
NotCertified: isCertified == "false",
|
NotCertified: isCertified == "false",
|
||||||
InnerCircle: isCertified == "circle",
|
InnerCircle: isCertified == "circle",
|
||||||
ShyAccounts: isCertified == "shy",
|
ShyAccounts: isCertified == "shy",
|
||||||
|
IsBanned: isCertified == "banned",
|
||||||
Friends: friendSearch,
|
Friends: friendSearch,
|
||||||
AgeMin: ageMin,
|
AgeMin: ageMin,
|
||||||
AgeMax: ageMax,
|
AgeMax: ageMax,
|
||||||
|
|
|
@ -168,6 +168,7 @@ type UserSearch struct {
|
||||||
NotCertified bool
|
NotCertified bool
|
||||||
InnerCircle bool
|
InnerCircle bool
|
||||||
ShyAccounts bool
|
ShyAccounts bool
|
||||||
|
IsBanned bool
|
||||||
Friends bool
|
Friends bool
|
||||||
AgeMin int
|
AgeMin int
|
||||||
AgeMax int
|
AgeMax int
|
||||||
|
@ -267,16 +268,28 @@ func SearchUsers(user *User, search *UserSearch, pager *Pagination) ([]*User, er
|
||||||
placeholders = append(placeholders, "here_for", "%"+search.HereFor+"%")
|
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)
|
// Certified filter (including if Shy Accounts are asked for)
|
||||||
if search.Certified {
|
if search.Certified {
|
||||||
wheres = append(wheres, "certified = ?", "status = ?")
|
wheres = append(wheres, "certified = ?")
|
||||||
placeholders = append(placeholders, search.Certified, UserStatusActive)
|
placeholders = append(placeholders, search.Certified)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expressly Not Certified filtering
|
// Expressly Not Certified filtering
|
||||||
if search.NotCertified {
|
if search.NotCertified {
|
||||||
wheres = append(wheres, "certified = ?", "status = ?")
|
wheres = append(wheres, "certified = ?")
|
||||||
placeholders = append(placeholders, false, UserStatusActive)
|
placeholders = append(placeholders, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if search.InnerCircle {
|
if search.InnerCircle {
|
||||||
|
|
|
@ -88,6 +88,9 @@
|
||||||
<option value="shy"{{if eq $Root.Certified "shy"}} selected{{end}}>Shy Accounts</option>
|
<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="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>
|
<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>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user