mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 09:42:36 +02:00
Fix validating education class tag whitelist
This commit is contained in:
parent
7887553666
commit
beafd2daf8
1 changed files with 13 additions and 3 deletions
|
@ -1,7 +1,12 @@
|
||||||
CREATE_MATCH_REGEX = /^username$|^password$|^email$|^new_tags_string$|^is_education$/
|
CREATE_MATCH_REGEX = /^username$|^password$|^email$|^new_tags_string$|^is_education$/
|
||||||
|
|
||||||
|
def education_whitelist_required?
|
||||||
|
return true if params[:is_education] == 'true' && $config['education_tag_whitelist']
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
def education_whitelisted?
|
def education_whitelisted?
|
||||||
return true if params[:is_education] == 'true' && $config['education_tag_whitelist'] && !$config['education_tag_whitelist'].select {|t| params[:new_tags_string].match(t)}.empty?
|
return true if education_whitelist_required? && !$config['education_tag_whitelist'].select {|t| params[:new_tags_string].match(t)}.empty?
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -63,8 +68,13 @@ post '/create' do
|
||||||
ga_adgroupid: session[:ga_adgroupid]
|
ga_adgroupid: session[:ga_adgroupid]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if education_whitelist_required?
|
||||||
if education_whitelisted?
|
if education_whitelisted?
|
||||||
@site.email_confirmed = true
|
@site.email_confirmed = true
|
||||||
|
else
|
||||||
|
flash[:error] = 'The class tag is invalid.'
|
||||||
|
return {result: 'error'}.to_json
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if !hcaptcha_valid?
|
if !hcaptcha_valid?
|
||||||
flash[:error] = 'The captcha was not valid, please try again.'
|
flash[:error] = 'The captcha was not valid, please try again.'
|
||||||
|
|
Loading…
Add table
Reference in a new issue