Improve allowed language handling (#2897)
* Dont allow empty value in user allowed languages * Sanitize language input to reject blank values in array
This commit is contained in:
parent
0291b73de7
commit
bba537a7be
4 changed files with 27 additions and 1 deletions
|
@ -52,6 +52,8 @@ class User < ApplicationRecord
|
|||
scope :admins, -> { where(admin: true) }
|
||||
scope :confirmed, -> { where.not(confirmed_at: nil) }
|
||||
|
||||
before_validation :sanitize_languages
|
||||
|
||||
def confirmed?
|
||||
confirmed_at.present?
|
||||
end
|
||||
|
@ -77,4 +79,10 @@ class User < ApplicationRecord
|
|||
def setting_auto_play_gif
|
||||
settings.auto_play_gif
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def sanitize_languages
|
||||
allowed_languages.reject!(&:blank?)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue