mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Redirects containing Unicode usernames didn't work
This commit is contained in:
@@ -760,7 +760,7 @@ class ApplicationController < ActionController::Base
|
||||
return if !current_user
|
||||
return if !should_enforce_2fa?
|
||||
|
||||
redirect_path = "#{GlobalSetting.relative_url_root}/u/#{current_user.username}/preferences/second-factor"
|
||||
redirect_path = path("/u/#{current_user.encoded_username}/preferences/second-factor")
|
||||
if !request.fullpath.start_with?(redirect_path)
|
||||
redirect_to path(redirect_path)
|
||||
nil
|
||||
|
||||
@@ -7,7 +7,7 @@ class EmailController < ApplicationController
|
||||
before_action :ensure_logged_in, only: :preferences_redirect
|
||||
|
||||
def preferences_redirect
|
||||
redirect_to(email_preferences_path(current_user.username_lower))
|
||||
redirect_to path("/u/#{current_user.encoded_username}/preferences/emails")
|
||||
end
|
||||
|
||||
def unsubscribe
|
||||
|
||||
@@ -109,7 +109,7 @@ class UserAvatarsController < ApplicationController
|
||||
|
||||
if !Discourse.avatar_sizes.include?(size) && Discourse.store.external?
|
||||
closest = Discourse.avatar_sizes.to_a.min { |a, b| (size - a).abs <=> (size - b).abs }
|
||||
avatar_url = UserAvatar.local_avatar_url(hostname, user.username_lower, upload_id, closest)
|
||||
avatar_url = UserAvatar.local_avatar_url(hostname, user.encoded_username(lower: true), upload_id, closest)
|
||||
return redirect_to cdn_path(avatar_url)
|
||||
end
|
||||
|
||||
@@ -117,7 +117,7 @@ class UserAvatarsController < ApplicationController
|
||||
upload ||= user.uploaded_avatar if user.uploaded_avatar_id == upload_id
|
||||
|
||||
if user.uploaded_avatar && !upload
|
||||
avatar_url = UserAvatar.local_avatar_url(hostname, user.username_lower, user.uploaded_avatar_id, size)
|
||||
avatar_url = UserAvatar.local_avatar_url(hostname, user.encoded_username(lower: true), user.uploaded_avatar_id, size)
|
||||
return redirect_to cdn_path(avatar_url)
|
||||
elsif upload && optimized = get_optimized_image(upload, size)
|
||||
if optimized.local?
|
||||
|
||||
@@ -130,7 +130,7 @@ class UsersController < ApplicationController
|
||||
end
|
||||
|
||||
def user_preferences_redirect
|
||||
redirect_to email_preferences_path(current_user.username_lower)
|
||||
redirect_to path("/u/#{current_user.encoded_username}/preferences")
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -273,7 +273,7 @@ class UsersController < ApplicationController
|
||||
cookies[:destination_url] = path("/my/#{params[:path]}")
|
||||
redirect_to path("/login-preferences")
|
||||
else
|
||||
redirect_to(path("/u/#{current_user.username}/#{params[:path]}"))
|
||||
redirect_to(path("/u/#{current_user.encoded_username}/#{params[:path]}"))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user