Bugfixes around banned user accounts

face-detect
Noah Petherbridge 2023-03-09 16:57:38 -08:00
parent 0cdfcbb976
commit df65b1b260
5 changed files with 34 additions and 5 deletions

View File

@ -46,7 +46,7 @@ func UserPhotos() http.HandlerFunc {
var (
isOwnPhotos = currentUser.ID == user.ID
isShy = currentUser.IsShy()
isShyFrom = currentUser.IsShyFrom(user) || (isShy && !models.AreFriends(currentUser.ID, user.ID))
isShyFrom = !isOwnPhotos && (currentUser.IsShyFrom(user) || (isShy && !models.AreFriends(currentUser.ID, user.ID)))
)
// Bail early if we are shy from this user.

View File

@ -95,6 +95,19 @@ func CertRequired(handler http.Handler) http.Handler {
return
}
// Are they banned or disabled?
if currentUser.Status == models.UserStatusDisabled {
session.LogoutUser(w, r)
session.FlashError(w, r, "Your account has been disabled and you are now logged out.")
templates.Redirect(w, "/")
return
} else if currentUser.Status == models.UserStatusBanned {
session.LogoutUser(w, r)
session.FlashError(w, r, "Your account has been banned and you are now logged out.")
templates.Redirect(w, "/")
return
}
// User must be certified.
if !currentUser.Certified || currentUser.ProfilePhoto.ID == 0 {
log.Error("CertRequired: user is not certified")

View File

@ -245,8 +245,8 @@ func SearchUsers(user *User, search *UserSearch, pager *Pagination) ([]*User, er
}
if search.Certified {
wheres = append(wheres, "certified = ?")
placeholders = append(placeholders, search.Certified)
wheres = append(wheres, "certified = ?", "status = ?")
placeholders = append(placeholders, search.Certified, UserStatusActive)
}
if search.AgeMin > 0 {

View File

@ -184,7 +184,11 @@
<div class="media-content">
<p class="title is-4">
<a href="/u/{{.Username}}" class="has-text-dark">
{{.NameOrUsername}}
{{if ne .Status "active"}}
<del>{{.NameOrUsername}}</del>
{{else}}
{{.NameOrUsername}}
{{end}}
</a>
{{if eq .Visibility "private"}}
<sup class="fa fa-mask is-size-7" title="Private Profile"></sup>
@ -200,6 +204,9 @@
</span>
{{end}}
<!-- "(banned)" label -->
{{if ne .Status "active"}}<small>({{.Status}})</small>{{end}}
{{if .IsAdmin}}
<span class="has-text-danger">
<span class="icon"><i class="fa fa-gavel"></i></span>

View File

@ -88,7 +88,13 @@
</div>
<div class="media-content">
<p class="title is-4">
<a href="/u/{{.Username}}" class="has-text-dark">{{.NameOrUsername}}</a>
<a href="/u/{{.Username}}" class="has-text-dark">
{{if ne .Status "active"}}
<del>{{.NameOrUsername}}</del>
{{else}}
{{.NameOrUsername}}
{{end}}
</a>
</p>
<p class="subtitle is-6">
<span class="icon"><i class="fa fa-user"></i></span>
@ -100,6 +106,9 @@
</span>
{{end}}
<!-- "(banned)" label -->
{{if ne .Status "active"}}<small>({{.Status}})</small>{{end}}
{{if .IsAdmin}}
<span class="has-text-danger">
<span class="icon"><i class="fa fa-gavel"></i></span>