# Offense count: 72
Metrics/PerceivedComplexity:
- Max: 23
+ Max: 25
# Offense count: 6
Naming/AccessorMethodName:
var copyright = I18n.t("javascripts.map.copyright", { copyright_url: "/copyright" });
var donate = I18n.t("javascripts.map.donate_link_text", { donate_url: "https://donate.openstreetmap.org" });
+ var terms = I18n.t("javascripts.map.terms", { terms_url: "https://wiki.osmfoundation.org/wiki/Terms_of_Use" });
this.baseLayers = [];
this.baseLayers.push(new L.OSM.Mapnik({
- attribution: copyright + " ♥ " + donate,
+ attribution: copyright + " ♥ " + donate + ". " + terms,
code: "M",
keyid: "mapnik",
name: I18n.t("javascripts.map.base.standard")
if (OSM.THUNDERFOREST_KEY) {
this.baseLayers.push(new L.OSM.CycleMap({
- attribution: copyright + ". Tiles courtesy of <a href='https://www.thunderforest.com/' target='_blank'>Andy Allan</a>",
+ attribution: copyright + ". Tiles courtesy of <a href='https://www.thunderforest.com/' target='_blank'>Andy Allan</a>. " + terms,
apikey: OSM.THUNDERFOREST_KEY,
code: "C",
keyid: "cyclemap",
}));
this.baseLayers.push(new L.OSM.TransportMap({
- attribution: copyright + ". Tiles courtesy of <a href='https://www.thunderforest.com/' target='_blank'>Andy Allan</a>",
+ attribution: copyright + ". Tiles courtesy of <a href='https://www.thunderforest.com/' target='_blank'>Andy Allan</a>. " + terms,
apikey: OSM.THUNDERFOREST_KEY,
code: "T",
keyid: "transportmap",
}
this.baseLayers.push(new L.OSM.HOT({
- attribution: copyright + ". Tiles style by <a href='https://www.hotosm.org/' target='_blank'>Humanitarian OpenStreetMap Team</a> hosted by <a href='https://openstreetmap.fr/' target='_blank'>OpenStreetMap France</a>",
+ attribution: copyright + ". Tiles style by <a href='https://www.hotosm.org/' target='_blank'>Humanitarian OpenStreetMap Team</a> hosted by <a href='https://openstreetmap.fr/' target='_blank'>OpenStreetMap France</a>. " + terms,
code: "H",
keyid: "hot",
name: I18n.t("javascripts.map.base.hot")
$("#contributorTerms").html("<img src='" + OSM.SEARCHING + "' />");
$("#contributorTerms").load(url);
});
+
+ $("#read_ct").on("click", function () {
+ $("#continue").prop("disabled", !($(this).prop("checked") && $("#read_tou").prop("checked")));
+ });
+
+ $("#read_tou").on("click", function () {
+ $("#continue").prop("disabled", !($(this).prop("checked") && $("#read_ct").prop("checked")));
+ });
});
def save
@title = t "users.new.title"
- if params[:decline]
+ if params[:decline] || !(params[:read_tou] && params[:read_ct])
if current_user
current_user.terms_seen = true
else
redirect_to :action => :account, :display_name => current_user.display_name
end
- else
+ elsif params[:decline]
redirect_to t("users.terms.declined")
+ else
+ redirect_to :action => :terms
end
elsif current_user
unless current_user.terms_agreed?
current_user.consider_pd = params[:user][:consider_pd]
+ current_user.tou_agreed = Time.now.getutc
current_user.terms_agreed = Time.now.getutc
current_user.terms_seen = true
current_user.creation_ip = request.remote_ip
current_user.languages = http_accept_language.user_preferred_languages
current_user.terms_agreed = Time.now.getutc
+ current_user.tou_agreed = Time.now.getutc
current_user.terms_seen = true
if current_user.auth_uid.blank?
# image_content_type :string
# auth_provider :string
# home_tile :integer
+# tou_agreed :datetime
#
# Indexes
#
<%= form_tag({ :action => "save" }, { :class => " inner22 standard-form fillL" }) do %>
<!-- legale is <%= @legale %> -->
+ <p class="deemphasize"><%= t ".read and accept with tou" %></p>
+ <label class="standard-label">
+ <%= t ".heading_ct" %>
+ </label>
<div class='form-row horizontal-list'>
+ <p class="deemphasize"><%= t ".contributor_terms_explain" %></p>
<label class="standard-label">
<%= t ".legale_select" %>
</label>
<%= render :partial => "terms" %>
</div>
+ <div>
+ <p id="contributorGuidance" class="deemphasize">
+ <%= raw t ".guidance",
+ :summary => "https://www.osmfoundation.org/wiki/License/Contributor_Terms_Summary",
+ :translations => "https://www.osmfoundation.org/wiki/License/Contributor_Terms/Informal_Translations" %>
+ </p>
+ </div>
<div class="form-row">
- <label for="user_consider_pd">
- <%= check_box("user", "consider_pd") %>
- <%= t ".consider_pd" %>
+ <label for="read_ct">
+ <%= check_box_tag "read_ct" %>
+ <%= t ".read_ct" %>
+ </label>
+ </div>
+
+ <label class="standard-label">
+ <%= t "layouts.tou" %>
+ </label>
+ <p class="deemphasize"><%= t ".tou_explain_html", :tou_link => link_to(t("layouts.tou"), "https://wiki.osmfoundation.org/wiki/Terms_of_Use", :target => :new) %></p>
+ <div class="form-row">
+ <label for="read_tou">
+ <%= check_box_tag "read_tou" %>
+ <%= t ".read_tou" %>
</label>
- <span class="minorNote">(<%= link_to(t(".consider_pd_why"), t(".consider_pd_why_url"), :target => :new) %>)</span>
<%= hidden_field_tag("referer", h(params[:referer])) unless params[:referer].nil? %>
<div class="buttons form-row inner20 clearfix">
- <p class="deemphasize"><%= t ".read and accept" %></p>
- <%= submit_tag(t(".agree"), :name => "agree", :id => "agree") %>
- <%= submit_tag(t(".decline"), :name => "decline", :id => "decline") %>
+ <%= submit_tag("Continue", :name => "continue", :id => "continue", :disabled => true) %>
+ <%= submit_tag("Cancel", :name => "decline", :id => "decline") %>
</div>
- <div class="deemphasize">
- <p id="contributorGuidance">
- <%= raw t ".guidance",
- :summary => "https://www.osmfoundation.org/wiki/License/Contributor_Terms_Summary",
- :translations => "https://www.osmfoundation.org/wiki/License/Contributor_Terms/Informal_Translations" %>
- </p>
- </div>
+ <label for="user_consider_pd">
+ <%= check_box("user", "consider_pd") %>
+ <%= t ".consider_pd" %>
+ </label>
+ <span class="minorNote">(<%= link_to(t(".consider_pd_why"), t(".consider_pd_why_url"), :target => :new) %>)</span>
+
</div>
<% end %>
partners_ucl: "UCL"
partners_bytemark: "Bytemark Hosting"
partners_partners: "partners"
+ tou: "Terms of Use"
osm_offline: "The OpenStreetMap database is currently offline while essential database maintenance work is carried out."
osm_read_only: "The OpenStreetMap database is currently in read-only mode while essential database maintenance work is carried out."
donate: "Support OpenStreetMap by %{link} to the Hardware Upgrade Fund."
This site and many other related services are formally operated by the
<a href='https://osmfoundation.org/'>OpenStreetMap Foundation</a> (OSMF)
on behalf of the community. Use of all OSMF operated services is subject
- to our <a href="https://wiki.openstreetmap.org/wiki/Acceptable_Use_Policy">
+ to our <a href="https://wiki.osmfoundation.org/wiki/Terms_of_Use">Terms of Use</a>, <a href="https://wiki.openstreetmap.org/wiki/Acceptable_Use_Policy">
Acceptable Use Policies</a> and our <a href="https://wiki.osmfoundation.org/wiki/Privacy_Policy">Privacy Policy</a>
<br>
Please <a href='https://osmfoundation.org/Contact'>contact the OSMF</a>
terms declined: "We are sorry that you have decided to not accept the new Contributor Terms. For more information, please see <a href=\"%{url}\">this wiki page</a>."
terms declined url: https://wiki.openstreetmap.org/wiki/Contributor_Terms_Declined
terms:
- title: "Contributor terms"
- heading: "Contributor terms"
- read and accept: "Please read the agreement and press the agree button to confirm that you accept the terms of this agreement for your existing and future contributions."
- consider_pd: "In addition to the above agreement, I consider my contributions to be in the Public Domain"
+ title: "Terms"
+ heading: "Terms"
+ heading_ct: "Contributor terms"
+ read and accept with tou: "Please read the contributor agreement and the terms of use, check both checkboxes when done and then press the continue button."
+ contributor_terms_explain: "This agreement governs the terms for your existing and future contributions."
+ read_ct: "I have read and agree to the above contributor terms"
+ tou_explain_html: "These %{tou_link} govern the use of the website and other infrastructure provided by the OSMF. Please click on the link, read and aggree to the text."
+ read_tou: "I have read and agree to the Terms of Use"
+ consider_pd: "In addition to the above, I consider my contributions to be in the Public Domain"
consider_pd_why: "what's this?"
consider_pd_why_url: https://www.osmfoundation.org/wiki/License/Why_would_I_want_my_contributions_to_be_public_domain
guidance: 'Information to help understand these terms: a <a href="%{summary}">human readable summary</a> and some <a href="%{translations}">informal translations</a>'
- agree: Agree
+ continue: Continue
declined: "https://wiki.openstreetmap.org/wiki/Contributor_Terms_Declined"
decline: "Decline"
you need to accept or decline: "Please read and then either accept or decline the new Contributor Terms to continue."
title: "Layers"
copyright: "© <a href='%{copyright_url}'>OpenStreetMap contributors</a>"
donate_link_text: "<a class='donate-attr' href='%{donate_url}'>Make a Donation</a>"
+ terms: "<a href='%{terms_url}' target='_blank'>Website and API terms</a>"
site:
edit_tooltip: Edit the map
edit_disabled_tooltip: Zoom in to edit the map
--- /dev/null
+class AddUserTouAgreed < ActiveRecord::Migration[5.1]
+ def change
+ add_column :users, :tou_agreed, :datetime
+ end
+end
assert_difference "User.count", 1 do
assert_difference "ActionMailer::Base.deliveries.size", 1 do
perform_enqueued_jobs do
- post :save, :session => { :new_user => user }
+ post :save, :session => { :new_user => user }, :params => { :read_ct => 1, :read_tou => 1 }
end
end
end
assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
- post :save, :session => { :new_user => user }
+ post :save, :session => { :new_user => user }, :params => { :read_ct => 1, :read_tou => 1 }
end
end
end
assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
- post :save, :session => { :new_user => user }
+ post :save, :session => { :new_user => user }, :params => { :read_ct => 1, :read_tou => 1 }
end
end
end
assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
- post :save, :session => { :new_user => user }
+ post :save, :session => { :new_user => user }, :params => { :read_ct => 1, :read_tou => 1 }
end
end
end
assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
- post :save, :session => { :new_user => user }
+ post :save, :session => { :new_user => user }, :params => { :read_ct => 1, :read_tou => 1 }
end
end
end
assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
- post :save, :session => { :new_user => user }
+ post :save, :session => { :new_user => user }, :params => { :read_ct => 1, :read_tou => 1 }
end
end
end
assert_difference "ActionMailer::Base.deliveries.size", 1 do
perform_enqueued_jobs do
post :save, :session => { :new_user => user,
- :referer => "/edit?editor=id#map=1/2/3" }
+ :referer => "/edit?editor=id#map=1/2/3" },
+ :params => { :read_ct => 1, :read_tou => 1 }
end
end
end
assert_response :success
assert_template :terms
- post :save, :params => { :user => { :consider_pd => true } }
+ post :save, :params => { :user => { :consider_pd => true }, :read_ct => 1, :read_tou => 1 }
assert_response :redirect
assert_redirected_to :action => :account, :display_name => user.display_name
assert_equal "Thanks for accepting the new contributor terms!", flash[:notice]
assert_response :success
assert_template :terms
- post :save, :params => { :user => { :consider_pd => true }, :referer => "/test" }
+ post :save, :params => { :user => { :consider_pd => true }, :referer => "/test", :read_ct => 1, :read_tou => 1 }
assert_response :redirect
assert_redirected_to "/test"
assert_equal "Thanks for accepting the new contributor terms!", flash[:notice]
OmniAuth.config.test_mode = true
stub_request(:get, /.*gravatar.com.*d=404/).to_return(:status => 404)
+ stub_hostip_requests
end
def teardown
assert_difference("ActionMailer::Base.deliveries.size", 1) do
perform_enqueued_jobs do
post "/user/save",
- :headers => { "HTTP_ACCEPT_LANGUAGE" => locale.to_s }
+ :headers => { "HTTP_ACCEPT_LANGUAGE" => locale.to_s },
+ :params => { :read_ct => 1, :read_tou => 1 }
follow_redirect!
end
end
end
end
+ def test_user_create_no_tou_failure
+ I18n.available_locales.each do |locale|
+ new_email = "#{locale}newtester@osm.org"
+ display_name = "#{locale}_new_tester"
+
+ assert_difference("User.count", 0) do
+ assert_difference("ActionMailer::Base.deliveries.size", 0) do
+ perform_enqueued_jobs do
+ post "/user/new",
+ :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" } }
+ end
+ end
+ end
+
+ assert_redirected_to "/user/terms"
+
+ perform_enqueued_jobs do
+ post "/user/save",
+ :headers => { "HTTP_ACCEPT_LANGUAGE" => locale.to_s }
+ assert_redirected_to "/user/terms"
+ end
+
+ ActionMailer::Base.deliveries.clear
+ end
+ end
+
# Check that the user can successfully recover their password
def lost_password_recovery_success
# Open the lost password form
:params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :pass_crypt => password, :pass_crypt_confirmation => password }, :referer => referer }
assert_redirected_to "/user/terms"
post "/user/save",
- :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :pass_crypt => password, :pass_crypt_confirmation => password } }
+ :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :pass_crypt => password, :pass_crypt_confirmation => password }, :read_ct => 1, :read_tou => 1 }
follow_redirect!
end
end
assert_response :redirect
assert_redirected_to "/user/terms"
post "/user/save",
- :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "openid", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => password, :pass_crypt_confirmation => password } }
+ :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "openid", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => password, :pass_crypt_confirmation => password }, :read_ct => 1, :read_tou => 1 }
assert_response :redirect
follow_redirect!
end
assert_response :redirect
assert_redirected_to "/user/terms"
post "/user/save",
- :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "openid", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" } }
+ :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "openid", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" }, :read_ct => 1, :read_tou => 1 }
follow_redirect!
end
end
assert_response :redirect
assert_redirected_to "/user/terms"
post "/user/save",
- :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "google", :auth_uid => "123454321", :pass_crypt => password, :pass_crypt_confirmation => password } }
+ :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "google", :auth_uid => "123454321", :pass_crypt => password, :pass_crypt_confirmation => password }, :read_ct => 1, :read_tou => 1 }
assert_response :redirect
follow_redirect!
end
assert_response :redirect
assert_redirected_to "/user/terms"
post "/user/save",
- :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "google", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" } }
+ :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "google", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" }, :read_ct => 1, :read_tou => 1 }
follow_redirect!
end
end
assert_response :redirect
assert_redirected_to "/user/terms"
post "/user/save",
- :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "facebook", :auth_uid => "123454321", :pass_crypt => password, :pass_crypt_confirmation => password } }
+ :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "facebook", :auth_uid => "123454321", :pass_crypt => password, :pass_crypt_confirmation => password }, :read_ct => 1, :read_tou => 1 }
assert_response :redirect
follow_redirect!
end
assert_response :redirect
assert_redirected_to "/user/terms"
post "/user/save",
- :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "facebook", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" } }
+ :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "facebook", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" }, :read_ct => 1, :read_tou => 1 }
follow_redirect!
end
end
assert_response :redirect
assert_redirected_to "/user/terms"
post "/user/save",
- :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "windowslive", :auth_uid => "123454321", :pass_crypt => password, :pass_crypt_confirmation => password } }
+ :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "windowslive", :auth_uid => "123454321", :pass_crypt => password, :pass_crypt_confirmation => password }, :read_ct => 1, :read_tou => 1 }
assert_response :redirect
follow_redirect!
end
assert_response :redirect
assert_redirected_to "/user/terms"
post "/user/save",
- :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "windowslive", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" } }
+ :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "windowslive", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" }, :read_ct => 1, :read_tou => 1 }
follow_redirect!
end
end
assert_response :redirect
assert_redirected_to "/user/terms"
post "/user/save",
- :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "github", :auth_uid => "123454321", :pass_crypt => password, :pass_crypt_confirmation => password } }
+ :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "github", :auth_uid => "123454321", :pass_crypt => password, :pass_crypt_confirmation => password }, :read_ct => 1, :read_tou => 1 }
assert_response :redirect
follow_redirect!
end
assert_response :redirect
assert_redirected_to "/user/terms"
post "/user/save",
- :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "github", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" } }
+ :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "github", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" }, :read_ct => 1, :read_tou => 1 }
follow_redirect!
end
end
assert_response :redirect
assert_redirected_to "/user/terms"
post "/user/save",
- :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "wikipedia", :auth_uid => "123454321", :pass_crypt => password, :pass_crypt_confirmation => password } }
+ :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "wikipedia", :auth_uid => "123454321", :pass_crypt => password, :pass_crypt_confirmation => password }, :read_ct => 1, :read_tou => 1 }
assert_response :redirect
follow_redirect!
end
assert_response :redirect
assert_redirected_to "/user/terms"
post "/user/save",
- :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "wikipedia", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" } }
+ :params => { :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "wikipedia", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" }, :read_ct => 1, :read_tou => 1 }
follow_redirect!
end
end