mirror of
https://github.com/neocities/neocities.git
synced 2025-08-05 01:01:30 +02:00
Site creation is back online
This commit is contained in:
parent
6c4cacbd3e
commit
1aac62923d
2 changed files with 33 additions and 59 deletions
72
app.rb
72
app.rb
|
@ -507,70 +507,36 @@ post '/create_validate' do
|
|||
end
|
||||
|
||||
post '/create' do
|
||||
content_type :json
|
||||
require_unbanned_ip
|
||||
dashboard_if_signed_in
|
||||
|
||||
@site = Site.new(
|
||||
username: params[:username],
|
||||
password: params[:password],
|
||||
email: params[:email],
|
||||
new_tags_string: params[:tags],
|
||||
is_nsfw: params[:is_nsfw],
|
||||
ip: request.ip
|
||||
)
|
||||
|
||||
recaptcha_is_valid = ENV['RACK_ENV'] == 'test' || recaptcha_valid?
|
||||
|
||||
if @site.valid? && recaptcha_is_valid
|
||||
DB.transaction do
|
||||
if !params[:stripe_token].nil? && params[:stripe_token] != ''
|
||||
customer = Stripe::Customer.create(
|
||||
card: params[:stripe_token],
|
||||
description: @site.username,
|
||||
email: @site.email,
|
||||
plan: params[:selected_plan]
|
||||
)
|
||||
@site.stripe_customer_id = customer.id
|
||||
|
||||
plan_name = customer.subscriptions.first['plan']['name']
|
||||
|
||||
EmailWorker.perform_async({
|
||||
from: 'web@neocities.org',
|
||||
reply_to: 'contact@neocities.org',
|
||||
to: @site.email,
|
||||
subject: "[Neocities] You've become a supporter!",
|
||||
body: Tilt.new('./views/templates/email_subscription.erb', pretty: true).render(self, plan_name: plan_name)
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
@site.save
|
||||
end
|
||||
|
||||
EmailWorker.perform_async({
|
||||
from: 'web@neocities.org',
|
||||
reply_to: 'contact@neocities.org',
|
||||
to: @site.email,
|
||||
subject: "[Neocities] Welcome to Neocities!",
|
||||
body: Tilt.new('./views/templates/email_welcome.erb', pretty: true).render(self)
|
||||
})
|
||||
|
||||
EmailWorker.perform_async({
|
||||
from: 'web@neocities.org',
|
||||
reply_to: 'contact@neocities.org',
|
||||
to: @site.email,
|
||||
subject: "[Neocities] Welcome to Neocities!",
|
||||
body: Tilt.new('./views/templates/email_welcome.erb', pretty: true).render(self)
|
||||
})
|
||||
|
||||
send_confirmation_email @site
|
||||
|
||||
session[:id] = @site.id
|
||||
redirect '/'
|
||||
else
|
||||
@site.errors.add :captcha, 'You must type in the captcha correctly! Try again.' if !recaptcha_is_valid
|
||||
|
||||
erb :'/new'
|
||||
if !@site.valid?
|
||||
return {result: 'error'}.to_json
|
||||
end
|
||||
|
||||
@site.save
|
||||
|
||||
EmailWorker.perform_async({
|
||||
from: 'web@neocities.org',
|
||||
reply_to: 'contact@neocities.org',
|
||||
to: @site.email,
|
||||
subject: "[Neocities] Welcome to Neocities!",
|
||||
body: Tilt.new('./views/templates/email_welcome.erb', pretty: true).render(self)
|
||||
})
|
||||
|
||||
send_confirmation_email @site
|
||||
|
||||
session[:id] = @site.id
|
||||
{result: 'ok'}.to_json
|
||||
end
|
||||
|
||||
get '/dashboard' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue