From f7550a0da8f6782dd12a683844394aca3b8e117b Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 12 Nov 2019 00:04:36 +0900 Subject: [PATCH] Change more suspension check logic From u.Status == UserSuspended to u.IsSuspended() Ref T661 --- account.go | 2 +- admin.go | 2 +- collections.go | 4 ++-- database.go | 2 +- invites.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/account.go b/account.go index 0faa7bb..25f1e0d 100644 --- a/account.go +++ b/account.go @@ -1053,7 +1053,7 @@ func viewSettings(app *App, u *User, w http.ResponseWriter, r *http.Request) err Email: fullUser.EmailClear(app.keys), HasPass: passIsSet, IsLogOut: r.FormValue("logout") == "1", - Suspended: fullUser.Status == UserSuspended, + Suspended: fullUser.IsSuspended(), } showUserPage(w, "settings", obj) diff --git a/admin.go b/admin.go index 65afd5f..2e5b8a5 100644 --- a/admin.go +++ b/admin.go @@ -242,7 +242,7 @@ func handleAdminToggleUserStatus(app *App, u *User, w http.ResponseWriter, r *ht log.Error("failed to get user: %v", err) return impart.HTTPError{http.StatusInternalServerError, fmt.Sprintf("Could not get user from username: %v", err)} } - if user.Status == UserSuspended { + if user.IsSuspended() { err = app.db.SetUserStatus(user.ID, UserActive) } else { err = app.db.SetUserStatus(user.ID, UserSuspended) diff --git a/collections.go b/collections.go index 38ec6f1..fe9d89f 100644 --- a/collections.go +++ b/collections.go @@ -906,10 +906,10 @@ func handleViewCollectionTag(app *App, w http.ResponseWriter, r *http.Request) e log.Error("Error getting user for collection: %v", err) } } - if !isOwner && u.Status == UserSuspended { + if !isOwner && u.IsSuspended() { return ErrCollectionNotFound } - displayPage.Suspended = u.Status == UserSuspended + displayPage.Suspended = u.IsSuspended() displayPage.Owner = owner coll.Owner = displayPage.Owner // Add more data diff --git a/database.go b/database.go index 4b0c702..4b4f4dc 100644 --- a/database.go +++ b/database.go @@ -322,7 +322,7 @@ func (db *datastore) IsUserSuspended(id int64) (bool, error) { return false, fmt.Errorf("is user suspended: %v", err) } - return u.Status == UserSuspended, nil + return u.IsSuspended(), nil } // DoesUserNeedAuth returns true if the user hasn't provided any methods for diff --git a/invites.go b/invites.go index 8f341ec..5f04c69 100644 --- a/invites.go +++ b/invites.go @@ -78,7 +78,7 @@ func handleCreateUserInvite(app *App, u *User, w http.ResponseWriter, r *http.Re muVal := r.FormValue("uses") expVal := r.FormValue("expires") - if u.Status == UserSuspended { + if u.IsSuspended() { return ErrUserSuspended }