FIX: Follow up fixes for password-reset error page (#18794)

* FIX: Follow up fixes for password-reset error page

Pass in `base_url` to the template
Use `.html_safe` since the message now contains html

Follow up to: 9b1536fb83

* Update specs to pass in the base_url
This commit is contained in:
Blake Erickson 2022-10-28 15:41:26 -06:00 committed by GitHub
parent f70d71c5e3
commit f7a4fd1f49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

View File

@ -1895,7 +1895,7 @@ class UsersController < ApplicationController
@user = User.find(user_id) if user_id > 0
end
@error = I18n.t('password_reset.no_token') if !@user
@error = I18n.t('password_reset.no_token', base_url: Discourse.base_url) if !@user
end
def respond_to_suspicious_request

View File

@ -1,7 +1,7 @@
<div id="simple-container">
<%if @error%>
<div class='alert alert-error'>
<%= @error %>
<%= @error.html_safe %>
</div>
<%end%>
<% if @user.present? and @user.errors.present? %>

View File

@ -178,7 +178,7 @@ RSpec.describe UsersController do
SiteSetting.login_required = true
get "/u/password-reset/#{token}"
expect(response.status).to eq(200)
expect(CGI.unescapeHTML(response.body)).to include(I18n.t('password_reset.no_token'))
expect(CGI.unescapeHTML(response.body)).to include(I18n.t('password_reset.no_token', base_url: Discourse.base_url))
end
end
@ -189,7 +189,7 @@ RSpec.describe UsersController do
expect(response.status).to eq(200)
expect(CGI.unescapeHTML(response.body))
.to include(I18n.t('password_reset.no_token'))
.to include(I18n.t('password_reset.no_token', base_url: Discourse.base_url))
expect(response.body).to_not have_tag(:script, with: {
src: '/assets/application.js'
@ -202,7 +202,7 @@ RSpec.describe UsersController do
get "/u/password-reset/#{token}.json"
expect(response.status).to eq(200)
expect(response.parsed_body["message"]).to eq(I18n.t('password_reset.no_token'))
expect(response.parsed_body["message"]).to eq(I18n.t('password_reset.no_token', base_url: Discourse.base_url))
expect(session[:current_user_id]).to be_blank
end
end
@ -214,7 +214,7 @@ RSpec.describe UsersController do
expect(response.status).to eq(200)
expect(CGI.unescapeHTML(response.body))
.to include(I18n.t('password_reset.no_token'))
.to include(I18n.t('password_reset.no_token', base_url: Discourse.base_url))
expect(response.body).to_not have_tag(:script, with: {
src: '/assets/application.js'
@ -227,7 +227,7 @@ RSpec.describe UsersController do
put "/u/password-reset/evil_trout!.json", params: { password: "awesomeSecretPassword" }
expect(response.status).to eq(200)
expect(response.parsed_body["message"]).to eq(I18n.t('password_reset.no_token'))
expect(response.parsed_body["message"]).to eq(I18n.t('password_reset.no_token', base_url: Discourse.base_url))
expect(session[:current_user_id]).to be_blank
end
end