fix password reset, fix ip blocker, turn off js for now

This commit is contained in:
Kyle Drake 2013-07-12 07:04:01 +02:00
parent 6245319bc1
commit 93f7918340
4 changed files with 21 additions and 8 deletions

6
app.rb
View file

@ -344,7 +344,7 @@ post '/admin/banhammer' do
} }
if !['127.0.0.1', nil, ''].include? site.ip if !['127.0.0.1', nil, ''].include? site.ip
`sudo ufw deny from #{site.ip}` `sudo ufw insert 1 deny from #{site.ip}`
end end
flash[:success] = 'MISSION ACCOMPLISHED' flash[:success] = 'MISSION ACCOMPLISHED'
@ -404,10 +404,10 @@ the NeoCities Cat
end end
get '/password_reset_confirm' do get '/password_reset_confirm' do
site = Site[password_reset_token: params[:token]] site = Site[password_reset_token: params[:code]]
if site if site
site.password = params[:token] site.password = params[:code]
site.save site.save
flash[:success] = 'Your password has been changed to the token sent in your e-mail. Please login and change your password in the settings page as soon as possible.' flash[:success] = 'Your password has been changed to the token sent in your e-mail. Please login and change your password in the settings page as soon as possible.'

View file

@ -55,6 +55,19 @@ if ENV['RACK_ENV'] == 'development' && Server.count == 0
Server.create ip: '127.0.0.1', slots_available: 999999 Server.create ip: '127.0.0.1', slots_available: 999999
end end
Mail.defaults do
#options = { :address => "smtp.gmail.com",
# :port => 587,
# :domain => 'your.host.name',
# :user_name => '<username>',
# :password => '<password>',
# :authentication => 'plain',
# :enable_starttls_auto => true }
options = {}
delivery_method :sendmail, options
end
class Sinatra::Base class Sinatra::Base
alias_method :render_original, :render alias_method :render_original, :render
def render(engine, data, options = {}, locals = {}, &block) def render(engine, data, options = {}, locals = {}, &block)

View file

@ -4,10 +4,10 @@ class EmailWorker
def perform(args={}) def perform(args={})
Mail.deliver do Mail.deliver do
from args[:from] from args['from']
to args[:to] to args['to']
subject args[:subject] subject args['subject']
body args[:body] body args['body']
end end
end end
end end

View file

@ -9,7 +9,7 @@ class ScreenshotWorker
screenshot = Tempfile.new 'neocities_screenshot' screenshot = Tempfile.new 'neocities_screenshot'
screenshot.close screenshot.close
caps = Selenium::WebDriver::Remote::Capabilities.htmlunit javascript_enabled: true, takesScreenshot: true caps = Selenium::WebDriver::Remote::Capabilities.htmlunit javascript_enabled: false, takesScreenshot: true
driver = Selenium::WebDriver.for :remote, url: $config['phantomjs_url'][rand($config['phantomjs_url'].length)], desired_capabilities: caps driver = Selenium::WebDriver.for :remote, url: $config['phantomjs_url'][rand($config['phantomjs_url'].length)], desired_capabilities: caps
driver.manage.window.resize_to 1280, 720 driver.manage.window.resize_to 1280, 720