FIX: Allow a user to remove their title

Somewhere there was a regression and a user couldn't remove their own
title. If they selected '(none)' in the UI it would say it was saved,
but it would not actually be updated in the db.
This commit is contained in:
Blake Erickson
2018-05-31 17:10:52 -06:00
parent 1a55948525
commit 7750b30016
2 changed files with 5 additions and 0 deletions

View File

@ -222,6 +222,7 @@ class Guardian
def can_grant_title?(user, title = nil)
return true if user && is_staff?
return false if title.nil?
return true if title.empty? # A title set to '(none)' in the UI is an empty string
return false if user != @user
return true if user.badges.where(name: title, allow_title: true).exists?
user.groups.where(title: title).exists?