Change more suspension check logic

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

Ref T661
pull/174/head
Matt Baer 5 years ago
parent 2c2ee0c00c
commit f7550a0da8
  1. 2
      account.go
  2. 2
      admin.go
  3. 4
      collections.go
  4. 2
      database.go
  5. 2
      invites.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)

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

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

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

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

Loading…
Cancel
Save