Merge branch 'staging' of https://github.com/FarmBot/Farmbot-Web-App into staging

pull/702/head
Rick Carlino 2018-03-07 09:03:08 -06:00
commit e91c982287
6 changed files with 29 additions and 15 deletions

View File

@ -33,6 +33,9 @@ class DashboardController < ApplicationController
klass = user.unconfirmed_email? ? Users::Reverify : Users::Verify
@token = klass.run!(user: user).to_json
render :confirmation_page, layout: false
rescue User::AlreadyVerified
@already_registered = true
render :confirmation_page, layout: false, status: 409
end
# Endpoint reports CSP violations, indicating a possible security problem.

View File

@ -28,6 +28,8 @@ class UserMailer < ApplicationMailer
end
def self.reset_url(user)
RESET_PATH % [$API_URL, user.confirmation_token]
x = URI(RESET_PATH % [$API_URL, user.confirmation_token])
(x.port = nil) if (x.port === 443) # Sendgrid does not like :443 in URLs.
x.to_s
end
end

View File

@ -1,9 +1,14 @@
<html>
<body>
You are being <%= link_to "redirected", app_landing_page_path %>.
<script>
localStorage.session = JSON.stringify(<%= raw @token %>)
window.location.replace("<%= app_landing_page_path %>");
</script>
<% if @already_registered %>
You have already verified your account.
Please <%= link_to "log in", "/" %>.
<% else %>
<p> You are now being <%= link_to "redirected", app_landing_page_path %>. </p>
<script>
localStorage.session = JSON.stringify(<%= raw @token %>)
window.location.replace("<%= app_landing_page_path %>");
</script>
<% end %>
</body>
</html>

View File

@ -0,0 +1,13 @@
describe DashboardController do
include Devise::Test::ControllerHelpers
let(:user) { FactoryBot.create(:user, confirmed_at: nil) }
render_views
it 'can not re-verify' do
user.update_attributes(confirmed_at: Time.now)
sign_in user
get :verify, params: { token: user.confirmation_token }
expect(response.status).to eq(409)
expect(response.body).to include("already verified")
end
end

View File

@ -50,14 +50,5 @@ describe DashboardController do
expect(user.reload.unconfirmed_email).to be nil
expect(user.email).to eq email
end
it 'can not re-verify' do
user.update_attributes(confirmed_at: Time.now)
sign_in user
expect do
get :verify, params: { token: user.confirmation_token }, format: :json
end.to raise_error(User::AlreadyVerified)
# expect(response.status).to eq(409)
end
end
end