DEV: Remove unused routes

This commit is contained in:
Gerhard Schlager 2020-06-05 18:42:12 +02:00
parent 8c6a42c589
commit 0bf753a739
5 changed files with 3 additions and 57 deletions

View File

@ -4,11 +4,6 @@ class EmailController < ApplicationController
layout 'no_ember'
skip_before_action :check_xhr, :preload_json, :redirect_to_login_if_required
before_action :ensure_logged_in, only: :preferences_redirect
def preferences_redirect
redirect_to path("/u/#{current_user.encoded_username}/preferences/emails")
end
def unsubscribe
@not_found = true

View File

@ -4,7 +4,7 @@ class UsersController < ApplicationController
skip_before_action :authorize_mini_profiler, only: [:avatar]
requires_login only: [
:username, :update, :user_preferences_redirect, :upload_user_image,
:username, :update, :upload_user_image,
:pick_avatar, :destroy_user_image, :destroy, :check_emails,
:topic_tracking_state, :preferences, :create_second_factor_totp,
:enable_second_factor_totp, :disable_second_factor, :list_second_factors,
@ -16,7 +16,7 @@ class UsersController < ApplicationController
skip_before_action :check_xhr, only: [
:show, :badges, :password_reset_show, :password_reset_update, :update, :account_created,
:activate_account, :perform_account_activation, :user_preferences_redirect, :avatar,
:activate_account, :perform_account_activation, :avatar,
:my_redirect, :toggle_anon, :admin_login, :confirm_admin, :email_login, :summary,
:feature_topic, :clear_featured_topic, :bookmarks
]
@ -129,10 +129,6 @@ class UsersController < ApplicationController
show
end
def user_preferences_redirect
redirect_to path("/u/#{current_user.encoded_username}/preferences")
end
def update
user = fetch_user_from_params
guardian.ensure_can_edit!(user)

View File

@ -315,8 +315,6 @@ Discourse::Application.routes.draw do
end # admin namespace
get "email_preferences" => "email#preferences_redirect", :as => "email_preferences_redirect"
get "email/unsubscribe/:key" => "email#unsubscribe", as: "email_unsubscribe"
get "email/unsubscribed" => "email#unsubscribed", as: "email_unsubscribed"
post "email/unsubscribe/:key" => "email#perform_unsubscribe", as: "email_perform_unsubscribe"
@ -374,7 +372,6 @@ Discourse::Application.routes.draw do
end
get "my/*path", to: 'users#my_redirect'
get "user_preferences" => "users#user_preferences_redirect"
get ".well-known/change-password", to: redirect(relative_url_root + 'my/preferences/account', status: 302)
get "user-cards" => "users#cards", format: :json
@ -442,7 +439,7 @@ Discourse::Application.routes.draw do
get({ "#{root_path}/:username" => "users#show", constraints: { username: RouteFormat.username } }.merge(index == 1 ? { as: 'user' } : {}))
put "#{root_path}/:username" => "users#update", constraints: { username: RouteFormat.username }, defaults: { format: :json }
get "#{root_path}/:username/emails" => "users#check_emails", constraints: { username: RouteFormat.username }
get({ "#{root_path}/:username/preferences" => "users#preferences", constraints: { username: RouteFormat.username } }.merge(index == 1 ? { as: :email_preferences } : {}))
get "#{root_path}/:username/preferences" => "users#preferences", constraints: { username: RouteFormat.username }
get "#{root_path}/:username/preferences/email" => "users_email#index", constraints: { username: RouteFormat.username }
get "#{root_path}/:username/preferences/account" => "users#preferences", constraints: { username: RouteFormat.username }
get "#{root_path}/:username/preferences/profile" => "users#preferences", constraints: { username: RouteFormat.username }

View File

@ -169,28 +169,6 @@ RSpec.describe EmailController do
end
end
context '#preferences_redirect' do
it 'requires you to be logged in' do
get "/email_preferences.json"
expect(response.status).to eq(403)
end
context 'when logged in' do
it 'redirects to your user preferences' do
user = sign_in(Fabricate(:user))
get "/email_preferences.json"
expect(response).to redirect_to("/u/#{user.username}/preferences/emails")
end
it "correctly redirects for Unicode usernames" do
SiteSetting.unicode_usernames = true
user = sign_in(Fabricate(:unicode_user))
get "/email_preferences.json"
expect(response).to redirect_to("/u/#{user.encoded_username}/preferences/emails")
end
end
end
context '#unsubscribe' do
it 'displays not found if key is not found' do
navigate_to_unsubscribe(SecureRandom.hex)

View File

@ -3496,26 +3496,6 @@ describe UsersController do
end
end
describe '#user_preferences_redirect' do
it 'requires the user to be logged in' do
get '/user_preferences'
expect(response.status).to eq(404)
end
it "redirects to their profile when logged in" do
sign_in(user)
get '/user_preferences'
expect(response).to redirect_to("/u/#{user.username}/preferences")
end
it "correctly redirects for Unicode usernames" do
SiteSetting.unicode_usernames = true
user = sign_in(Fabricate(:unicode_user))
get '/user_preferences'
expect(response).to redirect_to("/u/#{user.encoded_username}/preferences")
end
end
describe '#email_login' do
before do
SiteSetting.enable_local_logins_via_email = true