FIX: subfolder account activation (#28463)

This commit is contained in:
Renato Atilio 2024-08-21 13:50:38 -03:00 committed by GitHub
parent 70ea3f8fcd
commit 676f0897ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 36 additions and 8 deletions

View File

@ -10,6 +10,7 @@ import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error"; import { popupAjaxError } from "discourse/lib/ajax-error";
import { wavingHandURL } from "discourse/lib/waving-hand-url"; import { wavingHandURL } from "discourse/lib/waving-hand-url";
import i18n from "discourse-common/helpers/i18n"; import i18n from "discourse-common/helpers/i18n";
import getURL from "discourse-common/lib/get-url";
export default RouteTemplate( export default RouteTemplate(
class extends Component { class extends Component {
@ -26,12 +27,7 @@ export default RouteTemplate(
let hp; let hp;
try { try {
const response = await fetch("/session/hp", { hp = await ajax("/session/hp");
headers: {
Accept: "application/json",
},
});
hp = await response.json();
} catch (error) { } catch (error) {
this.isLoading = false; this.isLoading = false;
popupAjaxError(error); popupAjaxError(error);
@ -62,13 +58,18 @@ export default RouteTemplate(
} else if (response.needs_approval) { } else if (response.needs_approval) {
this.needsApproval = true; this.needsApproval = true;
} else { } else {
setTimeout(() => (window.location.href = "/"), 2000); setTimeout(this.loadHomepage, 2000);
} }
} catch (error) { } catch (error) {
this.errorMessage = i18n("user.activate_account.already_done"); this.errorMessage = i18n("user.activate_account.already_done");
} }
} }
@action
loadHomepage() {
window.location.href = getURL("/");
}
<template> <template>
{{hideApplicationSidebar}} {{hideApplicationSidebar}}
{{hideApplicationHeaderButtons "search" "login" "signup"}} {{hideApplicationHeaderButtons "search" "login" "signup"}}
@ -106,7 +107,7 @@ export default RouteTemplate(
"user.activate_account.continue_button" "user.activate_account.continue_button"
site_name=this.siteSettings.title site_name=this.siteSettings.title
}} }}
@href="/" @action={{this.loadHomepage}}
/> />
</p> </p>
{{/if}} {{/if}}

View File

@ -183,6 +183,33 @@ shared_examples "signup scenarios" do
expect(page).to have_css(".header-dropdown-toggle.current-user") expect(page).to have_css(".header-dropdown-toggle.current-user")
end end
end end
context "when site has subfolder install" do
before { set_subfolder "/discuss" }
it "can signup and activate account" do
visit("/discuss/signup")
signup_modal.fill_email("johndoe@example.com")
signup_modal.fill_username("john")
signup_modal.fill_password("supersecurepassword")
expect(signup_modal).to have_valid_fields
signup_modal.click_create_account
expect(page).to have_css(".account-created")
mail = ActionMailer::Base.deliveries.first
expect(mail.to).to contain_exactly("johndoe@example.com")
activation_link = mail.body.to_s[%r{\S+/u/activate-account/\S+}]
visit activation_link
activate_account.click_activate_account
activate_account.click_continue
expect(page).to have_current_path("/discuss/")
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
end
end end
context "when the email domain is blocked" do context "when the email domain is blocked" do