Change more suspension check logic

From u.Status == UserSuspended to u.IsSuspended()

Ref T661
This commit is contained in:
Matt Baer 2019-11-12 00:04:36 +09:00
parent 2c2ee0c00c
commit f7550a0da8
5 changed files with 6 additions and 6 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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
}