From 2d23a2601e744719f0696db209275cd85fdbb140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Thu, 9 May 2019 16:37:55 +0200 Subject: [PATCH 1/7] fix old photos without a remote_photo_path or remote_photo_name closes #8012 --- Changelog.md | 3 +++ .../20190509125709_fix_missing_remote_photo_fields.rb | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100644 db/migrate/20190509125709_fix_missing_remote_photo_fields.rb diff --git a/Changelog.md b/Changelog.md index 2dbd4123d..90b3bff77 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,9 @@ * Enable paranoid mode for devise [#8003](https://github.com/diaspora/diaspora/pull/8003) * Refactor likes cucumber test [#8002](https://github.com/diaspora/diaspora/pull/8002) +## Bug fixes +* Fix old photos without remote url for export [#8012](https://github.com/diaspora/diaspora/pull/8012) + ## Features * Add a manifest.json file as a first step to make diaspora\* a Progressive Web App [#7998](https://github.com/diaspora/diaspora/pull/7998) * Allow `web+diaspora://` links to link to a profile with only the diaspora ID [#8000](https://github.com/diaspora/diaspora/pull/8000) diff --git a/db/migrate/20190509125709_fix_missing_remote_photo_fields.rb b/db/migrate/20190509125709_fix_missing_remote_photo_fields.rb new file mode 100644 index 000000000..8d6462643 --- /dev/null +++ b/db/migrate/20190509125709_fix_missing_remote_photo_fields.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class FixMissingRemotePhotoFields < ActiveRecord::Migration[5.1] + def up + Photo.where(remote_photo_path: nil).each do |photo| + photo.write_attribute(:unprocessed_image, photo.read_attribute(:processed_image)) + photo.update_remote_path + photo.save! + end + end +end From 165b8f4f6e4e0a0c7a4577c1f3a9ffcb3d8a7a09 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sat, 11 May 2019 19:06:42 +0200 Subject: [PATCH 2/7] Don't encrypt the OTP secret It doesn't add any security to have this encrypted, but it adds complexity for podmins, because they need to backup the key. closes #8014 --- .gitignore | 1 - app/models/user.rb | 3 +- ...29175654_add_devise_two_factor_to_users.rb | 12 +++-- ...0190511150503_decrypt_two_factor_secret.rb | 52 +++++++++++++++++++ lib/configuration_methods.rb | 18 ------- lib/tasks/generate_2fa_encription_key.rake | 24 --------- spec/models/user_spec.rb | 4 +- 7 files changed, 61 insertions(+), 53 deletions(-) create mode 100644 db/migrate/20190511150503_decrypt_two_factor_secret.rb delete mode 100644 lib/tasks/generate_2fa_encription_key.rake diff --git a/.gitignore b/.gitignore index 48f5537ad..65d3c2649 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ app/assets/images/custom/ # Configuration files config/diaspora.yml config/initializers/secret_token.rb -config/initializers/twofa_encryption_key.rb .bundle vendor/bundle/ vendor/cache/ diff --git a/app/models/user.rb b/app/models/user.rb index 0f9336eca..8d30efa97 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -19,11 +19,10 @@ class User < ApplicationRecord scope :halfyear_actives, ->(time = Time.now) { logged_in_since(time - 6.month) } scope :active, -> { joins(:person).where(people: {closed_account: false}) } - attribute :otp_secret + attr_encrypted :otp_secret, if: false, prefix: "plain_" devise :two_factor_authenticatable, :two_factor_backupable, - otp_secret_encryption_key: AppConfig.twofa_encryption_key, otp_backup_code_length: 16, otp_number_of_backup_codes: 10 diff --git a/db/migrate/20171229175654_add_devise_two_factor_to_users.rb b/db/migrate/20171229175654_add_devise_two_factor_to_users.rb index f66a4e77e..47280dd20 100644 --- a/db/migrate/20171229175654_add_devise_two_factor_to_users.rb +++ b/db/migrate/20171229175654_add_devise_two_factor_to_users.rb @@ -2,10 +2,12 @@ class AddDeviseTwoFactorToUsers < ActiveRecord::Migration[5.1] def change - add_column :users, :encrypted_otp_secret, :string - add_column :users, :encrypted_otp_secret_iv, :string - add_column :users, :encrypted_otp_secret_salt, :string - add_column :users, :consumed_timestep, :integer - add_column :users, :otp_required_for_login, :boolean + change_table :users, bulk: true do |t| + t.string :encrypted_otp_secret + t.string :encrypted_otp_secret_iv + t.string :encrypted_otp_secret_salt + t.integer :consumed_timestep + t.boolean :otp_required_for_login + end end end diff --git a/db/migrate/20190511150503_decrypt_two_factor_secret.rb b/db/migrate/20190511150503_decrypt_two_factor_secret.rb new file mode 100644 index 000000000..b1d21f5f6 --- /dev/null +++ b/db/migrate/20190511150503_decrypt_two_factor_secret.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +class DecryptTwoFactorSecret < ActiveRecord::Migration[5.1] + class User < ApplicationRecord + end + + def up + add_column :users, :plain_otp_secret, :string + + key = twofa_encryption_key + decrypt_existing_secrets(key) if key + + change_table :users, bulk: true do |t| + t.remove :encrypted_otp_secret + t.remove :encrypted_otp_secret_iv + t.remove :encrypted_otp_secret_salt + end + end + + def down + raise ActiveRecord::IrreversibleMigration + end + + private + + def twofa_encryption_key + if AppConfig.heroku? + ENV["TWOFA_ENCRYPTION_KEY"] + else + key_file = File.expand_path("../../config/initializers/twofa_encryption_key.rb", File.dirname(__FILE__)) + + if File.exist? key_file + require key_file + File.delete(key_file) + + return Diaspora::Application.config.twofa_encryption_key + end + end + end + + def decrypt_existing_secrets(key) + User.where.not(encrypted_otp_secret: nil).each do |user| + user.plain_otp_secret = Encryptor.decrypt( + value: user.encrypted_otp_secret.unpack("m").first, + key: key, + iv: user.encrypted_otp_secret_iv.unpack("m").first, + salt: user.encrypted_otp_secret_salt.slice(1..-1).unpack("m").first + ) + user.save! + end + end +end diff --git a/lib/configuration_methods.rb b/lib/configuration_methods.rb index 487b70672..58a050f8c 100644 --- a/lib/configuration_methods.rb +++ b/lib/configuration_methods.rb @@ -68,24 +68,6 @@ module Configuration end end - def twofa_encryption_key - if heroku? - return ENV["TWOFA_ENCRYPTION_KEY"] if ENV["TWOFA_ENCRYPTION_KEY"] - - warn "FATAL: Running on Heroku with TWOFA_ENCRYPTION_KEY unset" - warn " Run heroku config:add TWOFA_ENCRYPTION_KEY=#{SecureRandom.hex(32)}" - abort - else - key_file = File.expand_path( - "../config/initializers/twofa_encryption_key.rb", - File.dirname(__FILE__) - ) - system "DISABLE_SPRING=1 bin/rake generate:twofa_key" unless File.exist? key_file - require key_file - Diaspora::Application.config.twofa_encryption_key - end - end - def version_string return @version_string unless @version_string.nil? diff --git a/lib/tasks/generate_2fa_encription_key.rake b/lib/tasks/generate_2fa_encription_key.rake deleted file mode 100644 index 53572f51f..000000000 --- a/lib/tasks/generate_2fa_encription_key.rake +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -namespace :generate do - desc "Generates a key for encrypting 2fa tokens" - task :twofa_key do - path = Rails.root.join("config", "initializers", "twofa_encryption_key.rb") - key = SecureRandom.hex(32) - File.open(path, "w") do |f| - f.write <<~CONF - # frozen_string_literal: true - - # The 2fa encryption key is used to encrypt users' OTP tokens in the database. - - # You can regenerate this key by running `rake generate:twofa_key` - - # If you change this key after a user has set up 2fa - # the users' tokens cannot be recovered - # and they will not be able to log in again! - - Diaspora::Application.config.twofa_encryption_key = "#{key}" - CONF - end - end -end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 13aa6fae8..560432927 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -984,9 +984,7 @@ describe User, :type => :model do exported_at exported_photos_at consumed_timestep - encrypted_otp_secret - encrypted_otp_secret_iv - encrypted_otp_secret_salt + plain_otp_secret otp_backup_codes otp_required_for_login otp_secret From e04ddd0bccba2b54912af59ae27b88653f9d3ad0 Mon Sep 17 00:00:00 2001 From: David Moseler Date: Sun, 20 Jan 2019 22:42:47 -0200 Subject: [PATCH 3/7] Clarify pod is part of diaspora in splash screen --- app/assets/stylesheets/home.scss | 10 ++++++++++ app/views/home/default.haml | 2 ++ config/locales/diaspora/en.yml | 1 + 3 files changed, 13 insertions(+) diff --git a/app/assets/stylesheets/home.scss b/app/assets/stylesheets/home.scss index 1dd6555ad..71795fa70 100644 --- a/app/assets/stylesheets/home.scss +++ b/app/assets/stylesheets/home.scss @@ -42,6 +42,16 @@ padding: 15px; } + .clarification-header { + background-color: $grey; + border: 1px solid $border-grey; + display: inline-block; + margin-bottom: 10px; + margin-top: 10px; + padding: 5px; + text-align: center; + } + .login-form { fieldset { background: none; } diff --git a/app/views/home/default.haml b/app/views/home/default.haml index 2a7a789c7..177b4d048 100644 --- a/app/views/home/default.haml +++ b/app/views/home/default.haml @@ -4,6 +4,8 @@ .row .col-md-8.text-center %h1= t("home.default.headline", pod_name: pod_name) + - if pod_name != "diaspora*" + %h2.clarification-header= t("home.default.clarify") %h2= t("home.default.byline") .col-md-4.login-form = render partial: "sessions/form", locals: {mobile: false, resource: User.new, resource_name: :user} diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 6e8a8a096..101925fcd 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -553,6 +553,7 @@ en: home: default: headline: "Welcome to %{pod_name}" + clarify: "Part of the diaspora* federated network" byline: "The online social world where you are in control" be_who_you_want_to_be: "Be who you want to be" be_who_you_want_to_be_info: "A lot of networks insist that you use your real identity. Not diaspora*. Here you can choose who you want to be, and share as much or as little about yourself as you want. It really is up to you how you want to interact with other people." From 6826e89a95f5ab6e3e6c0bffce0d68a1daf6594a Mon Sep 17 00:00:00 2001 From: flaburgan Date: Wed, 8 May 2019 22:42:08 +0200 Subject: [PATCH 4/7] Change design, add a link to the official website fixes #7910 closes #7966 --- Changelog.md | 1 + app/assets/stylesheets/home.scss | 14 ++++++-------- app/views/home/default.haml | 4 +++- config/locales/diaspora/en.yml | 3 ++- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Changelog.md b/Changelog.md index 30e39af59..b0818162a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,6 +5,7 @@ ## Bug fixes ## Features +* Add line mentioning diaspora\* on the splash page [#7966](https://github.com/diaspora/diaspora/pull/7966) # 0.7.11.0 diff --git a/app/assets/stylesheets/home.scss b/app/assets/stylesheets/home.scss index 71795fa70..147f4386a 100644 --- a/app/assets/stylesheets/home.scss +++ b/app/assets/stylesheets/home.scss @@ -42,14 +42,12 @@ padding: 15px; } - .clarification-header { - background-color: $grey; - border: 1px solid $border-grey; - display: inline-block; - margin-bottom: 10px; - margin-top: 10px; - padding: 5px; - text-align: center; + .part-of-diaspora { + font-style: italic; + + a { + color: $white; + } } .login-form { diff --git a/app/views/home/default.haml b/app/views/home/default.haml index 177b4d048..bf948f68a 100644 --- a/app/views/home/default.haml +++ b/app/views/home/default.haml @@ -5,7 +5,9 @@ .col-md-8.text-center %h1= t("home.default.headline", pod_name: pod_name) - if pod_name != "diaspora*" - %h2.clarification-header= t("home.default.clarify") + %h2.part-of-diaspora + != t("home.default.part_of_diaspora", + diaspora_site_link: link_to(t("home.default.diaspora_site_link"), "https://diasporafoundation.org/")) %h2= t("home.default.byline") .col-md-4.login-form = render partial: "sessions/form", locals: {mobile: false, resource: User.new, resource_name: :user} diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 101925fcd..f6434e66e 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -553,7 +553,8 @@ en: home: default: headline: "Welcome to %{pod_name}" - clarify: "Part of the diaspora* federated network" + part_of_diaspora: "Part of the %{diaspora_site_link}" + diaspora_site_link: "diaspora* federated network" byline: "The online social world where you are in control" be_who_you_want_to_be: "Be who you want to be" be_who_you_want_to_be_info: "A lot of networks insist that you use your real identity. Not diaspora*. Here you can choose who you want to be, and share as much or as little about yourself as you want. It really is up to you how you want to interact with other people." From 469983a6239da6f68d5d8160176bab25ffb38460 Mon Sep 17 00:00:00 2001 From: alebor-5 Date: Mon, 15 Oct 2018 18:04:23 +0200 Subject: [PATCH 5/7] Improve communication about signing up on closed pods fixes #7767 --- app/assets/stylesheets/help.scss | 23 +++++++++++++++++ app/controllers/registrations_controller.rb | 8 ++++-- app/views/help/registration_closed.html.haml | 25 +++++++++++++++++++ .../help/registration_closed.mobile.haml | 11 ++++++++ app/views/layouts/_header_not_connected.haml | 2 +- config/locales/diaspora/en.yml | 4 +++ config/routes.rb | 1 + .../registrations_controller_spec.rb | 10 +++----- 8 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 app/views/help/registration_closed.html.haml create mode 100644 app/views/help/registration_closed.mobile.haml diff --git a/app/assets/stylesheets/help.scss b/app/assets/stylesheets/help.scss index c19e09439..3dfc335af 100644 --- a/app/assets/stylesheets/help.scss +++ b/app/assets/stylesheets/help.scss @@ -106,3 +106,26 @@ ul#help_nav { } } } + +.ball{ + background: image-url('branding/ball.png') no-repeat; + background-size: contain; + height: 633px; + max-width: 100%; +} + +.v-center { + display: table; + height: 633px; + } + +.content { + display: table-cell; + vertical-align: middle; + + h2 { + font-size: 35px; + margin: 12px; + text-align: left; + } +} diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 1224160fd..142563314 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -33,8 +33,12 @@ class RegistrationsController < Devise::RegistrationsController def check_registrations_open_or_valid_invite! return true if AppConfig.settings.enable_registrations? || invite.try(:can_be_used?) - flash[:error] = params[:invite] ? t("registrations.invalid_invite") : t("registrations.closed") - redirect_to new_user_session_path + if params[:invite] + flash[:error] = t("registrations.invalid_invite") + redirect_to new_user_session_path + else + redirect_to registration_closed_path + end end def invite diff --git a/app/views/help/registration_closed.html.haml b/app/views/help/registration_closed.html.haml new file mode 100644 index 000000000..ea794a5b2 --- /dev/null +++ b/app/views/help/registration_closed.html.haml @@ -0,0 +1,25 @@ +- content_for :page_title do + = AppConfig.settings.pod_name + " - " + t("devise.shared.links.sign_up_closed") + +.container + .row + .col-md-10.offset1 + .col-md-7.hidden-phone + %h1.ball + .col-md-5.v-center + .content + %h2 + = t("devise.shared.links.sign_up_closed") + + != t("help.closed_pod", + wiki: link_to("another pod", "https://diasporafoundation.org/getting_started/sign_up")) + + != t("help.find_pods", + poduptime: link_to("Poduptime", "https://podupti.me/")) + + != t("help.other_questions", + wiki: link_to("Wiki", "https://wiki.diasporafoundation.org/Choosing_a_pod")) + + + + diff --git a/app/views/help/registration_closed.mobile.haml b/app/views/help/registration_closed.mobile.haml new file mode 100644 index 000000000..f3822cc51 --- /dev/null +++ b/app/views/help/registration_closed.mobile.haml @@ -0,0 +1,11 @@ +%h2 + = t("devise.shared.links.sign_up_closed") + +!= t("help.closed_pod", + wiki: link_to("another pod", "https://diasporafoundation.org/getting_started/sign_up")) + +!= t("help.find_pods", + poduptime: link_to("Poduptime", "https://podupti.me/")) + +!= t("help.other_questions", + wiki: link_to("Wiki", "https://wiki.diasporafoundation.org/Choosing_a_pod")) diff --git a/app/views/layouts/_header_not_connected.haml b/app/views/layouts/_header_not_connected.haml index c8760e3cb..4ed08291c 100644 --- a/app/views/layouts/_header_not_connected.haml +++ b/app/views/layouts/_header_not_connected.haml @@ -1,5 +1,5 @@ %ul.nav.navbar-nav.navbar-right - - if AppConfig.settings.enable_registrations? && !current_page?(controller: "/registrations", action: :new) + - unless current_page?(controller: "/registrations", action: :new) %li= link_to t("devise.shared.links.sign_up"), new_user_registration_path, class: "login" - unless current_page?(controller: "/sessions", action: :new) %li= link_to t("devise.shared.links.sign_in"), new_user_session_path, class: "login" diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index f6434e66e..a3bb4eddf 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -346,6 +346,10 @@ en: tutorials: "tutorials" tutorial: "tutorial" irc: "IRC" + closed_pod: "This pod is currently closed to new registrations. However, you can still join the diaspora* network by registering on %{wiki}. Because all pods are interconnected, you will have access to the same content there." + find_pods: "You can find pods at %{poduptime}." + other_questions: "If you have any other questions regarding choosing a pod, checkout our %{wiki}." + choose_another: "Please, choose another pod" wiki: "wiki" faq: "FAQ" markdown: "Markdown" diff --git a/config/routes.rb b/config/routes.rb index 4115bf5ba..66b3ecf92 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -205,6 +205,7 @@ Rails.application.routes.draw do # Help get 'help' => 'help#faq', :as => 'help' + get "help/registration_closed" => "help#registration_closed", :as => "registration_closed" get 'help/:topic' => 'help#faq' #Protocol Url diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index c7063e728..c1aa7744c 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -25,16 +25,14 @@ describe RegistrationsController, type: :controller do AppConfig.settings.enable_registrations = false end - it "redirects #new to the login page" do + it "redirects #new to the registration closed page" do get :new - expect(flash[:error]).to eq(I18n.t("registrations.closed")) - expect(response).to redirect_to new_user_session_path + expect(response).to redirect_to registration_closed_path end - it "redirects #create to the login page" do + it "redirects #create to the registration closed page" do post :create, params: valid_params - expect(flash[:error]).to eq(I18n.t("registrations.closed")) - expect(response).to redirect_to new_user_session_path + expect(response).to redirect_to registration_closed_path end it "does not redirect if there is a valid invite token" do From 4feab5219e7c9943a98512001e9080dc2937bbc3 Mon Sep 17 00:00:00 2001 From: flaburgan Date: Thu, 2 May 2019 17:27:27 +0200 Subject: [PATCH 6/7] Use a partial to share code between mobile and desktop, add the new route to the RegistrationController, drop flash message for closed registrations --- app/assets/stylesheets/help.scss | 23 ----------------- app/assets/stylesheets/registration.scss | 16 +++++++----- app/controllers/registrations_controller.rb | 16 ++++++------ app/views/help/registration_closed.html.haml | 25 ------------------- app/views/registrations/_form.haml | 2 +- .../_registrations_closed.haml} | 0 app/views/registrations/new.haml | 15 ++++++----- .../registrations/registrations_closed.haml | 8 ++++++ .../registrations_closed.mobile.haml | 10 ++++++++ config/locales/diaspora/en.yml | 4 +-- config/routes.rb | 2 +- ...gns_up.feature => getting_started.feature} | 6 ++--- features/desktop/registrations.feature | 24 ++++++++++++++++++ ...signs_up.feature => registrations.feature} | 3 +-- features/step_definitions/session_steps.rb | 8 ++++++ features/step_definitions/user_steps.rb | 8 ------ .../registrations_controller_spec.rb | 15 +++++------ 17 files changed, 91 insertions(+), 94 deletions(-) delete mode 100644 app/views/help/registration_closed.html.haml rename app/views/{help/registration_closed.mobile.haml => registrations/_registrations_closed.haml} (100%) create mode 100644 app/views/registrations/registrations_closed.haml create mode 100644 app/views/registrations/registrations_closed.mobile.haml rename features/desktop/{signs_up.feature => getting_started.feature} (96%) create mode 100644 features/desktop/registrations.feature rename features/mobile/{signs_up.feature => registrations.feature} (93%) diff --git a/app/assets/stylesheets/help.scss b/app/assets/stylesheets/help.scss index 3dfc335af..c19e09439 100644 --- a/app/assets/stylesheets/help.scss +++ b/app/assets/stylesheets/help.scss @@ -106,26 +106,3 @@ ul#help_nav { } } } - -.ball{ - background: image-url('branding/ball.png') no-repeat; - background-size: contain; - height: 633px; - max-width: 100%; -} - -.v-center { - display: table; - height: 633px; - } - -.content { - display: table-cell; - vertical-align: middle; - - h2 { - font-size: 35px; - margin: 12px; - text-align: left; - } -} diff --git a/app/assets/stylesheets/registration.scss b/app/assets/stylesheets/registration.scss index 123161d6a..5fb2a2bc6 100644 --- a/app/assets/stylesheets/registration.scss +++ b/app/assets/stylesheets/registration.scss @@ -1,5 +1,4 @@ -.page-registrations.action-new, -.page-registrations.action-create { +.page-registrations { .ball { background: image-url('branding/ball.png') no-repeat; background-size: contain; @@ -12,19 +11,24 @@ height: 633px; } + @media (max-width: $screen-xs-max) { + .v-center { + height: auto; + } + } + .content { display: table-cell; vertical-align: middle; - h2 { + h1 { font-size: 35px; - margin: 12px; - text-align: center; + margin: 12px 0; } } form { - max-width: 400px; + max-width: 500px; } .captcha-img { diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 142563314..7ba743756 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -5,9 +5,9 @@ # the COPYRIGHT file. class RegistrationsController < Devise::RegistrationsController - before_action :check_registrations_open_or_valid_invite! + before_action :check_registrations_open_or_valid_invite!, except: :registrations_closed - layout -> { request.format == :mobile ? "application" : "with_header" } + layout -> { request.format == :mobile ? "application" : "with_header_with_footer" } def create @user = User.build(user_params) @@ -28,17 +28,17 @@ class RegistrationsController < Devise::RegistrationsController end end + def registrations_closed + render "registrations/registrations_closed" + end + private def check_registrations_open_or_valid_invite! return true if AppConfig.settings.enable_registrations? || invite.try(:can_be_used?) - if params[:invite] - flash[:error] = t("registrations.invalid_invite") - redirect_to new_user_session_path - else - redirect_to registration_closed_path - end + flash[:error] = t("registrations.invalid_invite") if params[:invite] + redirect_to registrations_closed_path end def invite diff --git a/app/views/help/registration_closed.html.haml b/app/views/help/registration_closed.html.haml deleted file mode 100644 index ea794a5b2..000000000 --- a/app/views/help/registration_closed.html.haml +++ /dev/null @@ -1,25 +0,0 @@ -- content_for :page_title do - = AppConfig.settings.pod_name + " - " + t("devise.shared.links.sign_up_closed") - -.container - .row - .col-md-10.offset1 - .col-md-7.hidden-phone - %h1.ball - .col-md-5.v-center - .content - %h2 - = t("devise.shared.links.sign_up_closed") - - != t("help.closed_pod", - wiki: link_to("another pod", "https://diasporafoundation.org/getting_started/sign_up")) - - != t("help.find_pods", - poduptime: link_to("Poduptime", "https://podupti.me/")) - - != t("help.other_questions", - wiki: link_to("Wiki", "https://wiki.diasporafoundation.org/Choosing_a_pod")) - - - - diff --git a/app/views/registrations/_form.haml b/app/views/registrations/_form.haml index 56bbb04fb..9cd6ce0f7 100644 --- a/app/views/registrations/_form.haml +++ b/app/views/registrations/_form.haml @@ -4,7 +4,7 @@ - if mobile %legend = image_tag("branding/logos/header-logo2x.png", height: 40, width: 40) - = t("aspects.aspect_stream.make_something") + = AppConfig.settings.pod_name - if mobile = f.label :email, t("registrations.new.email"), class: "control-label", id: "emailLabel" diff --git a/app/views/help/registration_closed.mobile.haml b/app/views/registrations/_registrations_closed.haml similarity index 100% rename from app/views/help/registration_closed.mobile.haml rename to app/views/registrations/_registrations_closed.haml diff --git a/app/views/registrations/new.haml b/app/views/registrations/new.haml index 96f9c2733..bf034f9da 100644 --- a/app/views/registrations/new.haml +++ b/app/views/registrations/new.haml @@ -1,12 +1,11 @@ #registration .container .row - .col-md-10.offset1 - .col-md-7.hidden-phone - %h1.ball - .col-md-5.v-center - .content.text-center - %h2#pod-name - = AppConfig.settings.pod_name + .col-sm-6.hidden-xs + .ball + .col-sm-6.col-xs-12.v-center + .content.text-center + %h1#pod-name + = AppConfig.settings.pod_name - = render partial: "form", locals: {mobile: false} + = render partial: "form", locals: {mobile: false} diff --git a/app/views/registrations/registrations_closed.haml b/app/views/registrations/registrations_closed.haml new file mode 100644 index 000000000..c84db60f6 --- /dev/null +++ b/app/views/registrations/registrations_closed.haml @@ -0,0 +1,8 @@ +#registration + .container + .row + .col-sm-6.hidden-xs + .ball + .col-sm-6.col-xs-12.v-center + .content + = render partial: "registrations_closed" diff --git a/app/views/registrations/registrations_closed.mobile.haml b/app/views/registrations/registrations_closed.mobile.haml new file mode 100644 index 000000000..255620aca --- /dev/null +++ b/app/views/registrations/registrations_closed.mobile.haml @@ -0,0 +1,10 @@ + +.stream#main-stream + - flash.each do |name, msg| + .expose#flash-container + .flash-message{class: "message alert alert-#{flash_class name}", role: "alert"} + = msg + + .login-form + .login-container + = render partial: "registrations_closed" diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index a3bb4eddf..9331f797d 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -347,8 +347,8 @@ en: tutorial: "tutorial" irc: "IRC" closed_pod: "This pod is currently closed to new registrations. However, you can still join the diaspora* network by registering on %{wiki}. Because all pods are interconnected, you will have access to the same content there." - find_pods: "You can find pods at %{poduptime}." - other_questions: "If you have any other questions regarding choosing a pod, checkout our %{wiki}." + find_pods: "There’s a list of pods you can sign up to at %{poduptime}." + other_questions: "If you have any other questions regarding choosing a pod, check out our %{wiki}." choose_another: "Please, choose another pod" wiki: "wiki" faq: "FAQ" diff --git a/config/routes.rb b/config/routes.rb index 66b3ecf92..8517e7ee8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -129,6 +129,7 @@ Rails.application.routes.draw do devise_scope :user do get "/users/sign_up" => "registrations#new", :as => :new_user_registration post "/users" => "registrations#create", :as => :user_registration + get "/registrations_closed" => "registrations#registrations_closed", :as => :registrations_closed end get "users/invitations" => "invitations#new", :as => "new_user_invitation" @@ -205,7 +206,6 @@ Rails.application.routes.draw do # Help get 'help' => 'help#faq', :as => 'help' - get "help/registration_closed" => "help#registration_closed", :as => "registration_closed" get 'help/:topic' => 'help#faq' #Protocol Url diff --git a/features/desktop/signs_up.feature b/features/desktop/getting_started.feature similarity index 96% rename from features/desktop/signs_up.feature rename to features/desktop/getting_started.feature index 2703069e0..bbebd5efa 100644 --- a/features/desktop/signs_up.feature +++ b/features/desktop/getting_started.feature @@ -98,11 +98,11 @@ Feature: new user registration Then I should not be able to sign up And I should have a validation error on "user_password, user_password_confirmation" - Scenario: User signs up with an already existing username and email and then tries to sign in (Issue #6136) + Scenario: User signs up with an already existing username and email and then tries to sign in When I log out manually And I go to the new user registration page - And I fill in the new user form with an existing email and username + And I fill in the new user form And I submit the form Then I should see a flash message indicating failure - When I click the sign in button + When I follow "Sign in" Then I should not see a flash message indicating failure diff --git a/features/desktop/registrations.feature b/features/desktop/registrations.feature new file mode 100644 index 000000000..1abcc09c4 --- /dev/null +++ b/features/desktop/registrations.feature @@ -0,0 +1,24 @@ +@javascript +Feature: New user registration + In order to use Diaspora* + As a desktop user + I want to register an account + + Scenario: user signs up and goes to getting started + Given I am on the new user registration page + When I fill in the new user form + And I press "Create account" + Then I should be on the getting started page + And I should see the 'getting started' contents + + Scenario: registrations are closed, user is informed + Given the registrations are closed + When I am on the new user registration page + Then I should see "Open signups are closed at this time" + + Scenario: User is unable to register even by manually sending the POST request + Given I am on the new user registration page + When I fill in the new user form + Given the registrations are closed + When I press "Create account" + Then I should see "Open signups are closed at this time" diff --git a/features/mobile/signs_up.feature b/features/mobile/registrations.feature similarity index 93% rename from features/mobile/signs_up.feature rename to features/mobile/registrations.feature index 3277ef131..43bc9dc75 100644 --- a/features/mobile/signs_up.feature +++ b/features/mobile/registrations.feature @@ -5,8 +5,7 @@ Feature: New user registration I want to register an account Background: - Given I am on the login page - And I follow "Create account" within "#main-nav" + Given I am on the new user registration page Scenario: user signs up and goes to getting started When I fill in the new user form diff --git a/features/step_definitions/session_steps.rb b/features/step_definitions/session_steps.rb index 4b08d1498..14d8f24ff 100644 --- a/features/step_definitions/session_steps.rb +++ b/features/step_definitions/session_steps.rb @@ -74,3 +74,11 @@ end Then (/^I should see the 'getting started' contents$/) do confirm_getting_started_contents end + +Given /^the registrations are closed$/ do + AppConfig.settings.enable_registrations = false +end + +When /^I fill in the new user form$/ do + fill_in_new_user_form +end diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index ee4e71b69..804642cae 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -218,20 +218,12 @@ When /^I view "([^\"]*)"'s first post$/ do |email| visit post_path(post) end -When /^I fill in the new user form/ do - fill_in_new_user_form -end - And /^I should be able to friend "([^\"]*)"$/ do |email| user = User.find_by_email(email) step 'I should see a ".aspect-dropdown"' step "I should see \"#{user.name}\"" end -When /^I click the sign in button$/ do - click_link "Sign in" -end - Given /^I did request my photos$/ do @me.perform_export_photos! end diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index c1aa7744c..7bb94bcaa 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -25,14 +25,14 @@ describe RegistrationsController, type: :controller do AppConfig.settings.enable_registrations = false end - it "redirects #new to the registration closed page" do + it "redirects #new to the registrations closed page" do get :new - expect(response).to redirect_to registration_closed_path + expect(response).to redirect_to registrations_closed_path end - it "redirects #create to the registration closed page" do + it "redirects #create to the registrations closed page" do post :create, params: valid_params - expect(response).to redirect_to registration_closed_path + expect(response).to redirect_to registrations_closed_path end it "does not redirect if there is a valid invite token" do @@ -43,7 +43,8 @@ describe RegistrationsController, type: :controller do it "does redirect if there is an invalid invite token" do get :new, params: {invite: {token: "fssdfsd"}} - expect(response).to redirect_to new_user_session_path + expect(flash[:error]).to eq(I18n.t("registrations.invalid_invite")) + expect(response).to redirect_to registrations_closed_path end it "does redirect if there are no invites available with this code" do @@ -51,7 +52,7 @@ describe RegistrationsController, type: :controller do code.update_attributes(count: 0) get :new, params: {invite: {token: code.token}} - expect(response).to redirect_to new_user_session_path + expect(response).to redirect_to registrations_closed_path end it "does redirect when invitations are closed now" do @@ -59,7 +60,7 @@ describe RegistrationsController, type: :controller do AppConfig.settings.invitations.open = false get :new, params: {invite: {token: code.token}} - expect(response).to redirect_to new_user_session_path + expect(response).to redirect_to registrations_closed_path end it "does not redirect when the registration is open" do From e5ba9a1a4696f30ba4e6e51893dbdd5c1c0cccca Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sat, 11 May 2019 22:53:57 +0200 Subject: [PATCH 7/7] Move translations to registrations.closed And remove unused translations and make "another pod" translatable. closes #7896 --- Changelog.md | 1 + app/views/registrations/_registrations_closed.haml | 8 ++++---- config/locales/diaspora/en.yml | 10 +++++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Changelog.md b/Changelog.md index b0818162a..904b9b895 100644 --- a/Changelog.md +++ b/Changelog.md @@ -6,6 +6,7 @@ ## Features * Add line mentioning diaspora\* on the splash page [#7966](https://github.com/diaspora/diaspora/pull/7966) +* Improve communication about signing up on closed pods [#7896](https://github.com/diaspora/diaspora/pull/7896) # 0.7.11.0 diff --git a/app/views/registrations/_registrations_closed.haml b/app/views/registrations/_registrations_closed.haml index f3822cc51..c1b9b3a8f 100644 --- a/app/views/registrations/_registrations_closed.haml +++ b/app/views/registrations/_registrations_closed.haml @@ -1,11 +1,11 @@ %h2 = t("devise.shared.links.sign_up_closed") -!= t("help.closed_pod", - wiki: link_to("another pod", "https://diasporafoundation.org/getting_started/sign_up")) +!= t("registrations.closed.closed_pod", + wiki: link_to(t("registrations.closed.another_pod"), "https://diasporafoundation.org/getting_started/sign_up")) -!= t("help.find_pods", +!= t("registrations.closed.find_pods", poduptime: link_to("Poduptime", "https://podupti.me/")) -!= t("help.other_questions", +!= t("registrations.closed.other_questions", wiki: link_to("Wiki", "https://wiki.diasporafoundation.org/Choosing_a_pod")) diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 9331f797d..fa3aa016f 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -346,10 +346,6 @@ en: tutorials: "tutorials" tutorial: "tutorial" irc: "IRC" - closed_pod: "This pod is currently closed to new registrations. However, you can still join the diaspora* network by registering on %{wiki}. Because all pods are interconnected, you will have access to the same content there." - find_pods: "There’s a list of pods you can sign up to at %{poduptime}." - other_questions: "If you have any other questions regarding choosing a pod, check out our %{wiki}." - choose_another: "Please, choose another pod" wiki: "wiki" faq: "FAQ" markdown: "Markdown" @@ -1056,7 +1052,11 @@ en: terms_link: "terms of service" create: success: "You’ve joined diaspora*!" - closed: "Signups are closed on this diaspora* pod." + closed: + closed_pod: "This pod is currently closed to new registrations. However, you can still join the diaspora* network by registering on %{wiki}. Because all pods are interconnected, you will have access to the same content there." + another_pod: "another pod" + find_pods: "There’s a list of pods you can sign up to at %{poduptime}." + other_questions: "If you have any other questions regarding choosing a pod, check out our %{wiki}." invalid_invite: "The invite link you provided is no longer valid!" reshares: