Skip to content

Commit

Permalink
check awk connection before starting the setup
Browse files Browse the repository at this point in the history
  • Loading branch information
colinyoung87 committed May 20, 2016
1 parent 9ac7cc5 commit efd7464
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/controllers/setup/single_site_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class SingleSiteController < ApplicationController
skip_before_action :run_first_time_setup
before_action :ensure_single_site_install, only: [:index, :create]
before_action :ensure_no_users, only: [:index, :create]
before_action :check_aws_credentials!, only: [:index, :create]

def index
@user = User.new
Expand Down Expand Up @@ -36,5 +37,14 @@ def ensure_single_site_install
def ensure_no_users
redirect_to root_url if current_team.users.count > 0
end

def check_aws_credentials!
s3 = AWS::S3.new
bucket = s3.buckets[ENV.fetch('AWS_S3_BUCKET')]
s3.buckets.create(ENV.fetch('AWS_S3_BUCKET')) if !bucket.exists?

rescue StandardError
render :invalid_aws_credentials
end
end
end
16 changes: 16 additions & 0 deletions app/views/setup/single_site/invalid_aws_credentials.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<ul class="steps h-list">
<li class="step">
<span class="number">1</span> Your account
</li>
<li class="step">
<span class="number">2</span> First Project
</li>
<li class="step">
<span class="number">3</span> Invite your team
</li>
</ul>

<div class="page-container">
<h2>AWS Credentials Error</h2>
<p>We failed to connect to your s3 bucket. Please check your AWS credentials and try again.</p>
</div>

0 comments on commit efd7464

Please sign in to comment.