DEV: Use query param for login-required welcome screen
With the full screen login page, on login required sites we want to show a welcome page. However, we should be able to also link directly to the login form. This commit adds a `welcome` query param to the login route, and shows the login form when this param is not present. This means links to "/login" will show the login form directly. And it also means routing between the welcome screen and the login form works as expected.
This commit is contained in:
parent
6912a1e3ca
commit
38c1692719
|
@ -35,7 +35,6 @@ export default class LoginPageController extends Controller {
|
|||
@tracked loggingIn = false;
|
||||
@tracked loggedIn = false;
|
||||
@tracked showLoginButtons = true;
|
||||
@tracked showLogin = true;
|
||||
@tracked showSecondFactor = false;
|
||||
@tracked loginPassword = "";
|
||||
@tracked loginName = "";
|
||||
|
@ -54,6 +53,7 @@ export default class LoginPageController extends Controller {
|
|||
@tracked secondFactorToken;
|
||||
@tracked flash;
|
||||
@tracked flashType;
|
||||
queryParams = ["welcome"];
|
||||
|
||||
get isAwaitingApproval() {
|
||||
return (
|
||||
|
@ -118,7 +118,7 @@ export default class LoginPageController extends Controller {
|
|||
|
||||
@action
|
||||
showLoginPage() {
|
||||
this.showLogin = true;
|
||||
this.router.transitionTo("login", { queryParams: { welcome: undefined } });
|
||||
}
|
||||
|
||||
@action
|
||||
|
|
|
@ -8,6 +8,10 @@ export default class LoginRoute extends DiscourseRoute {
|
|||
@service siteSettings;
|
||||
@service router;
|
||||
|
||||
queryParams = {
|
||||
welcome: { refreshModel: true },
|
||||
};
|
||||
|
||||
beforeModel() {
|
||||
if (
|
||||
!this.siteSettings.login_required &&
|
||||
|
@ -33,9 +37,5 @@ export default class LoginRoute extends DiscourseRoute {
|
|||
controller.set("canSignUp", canSignUp);
|
||||
controller.set("flashType", "");
|
||||
controller.set("flash", "");
|
||||
|
||||
if (this.siteSettings.login_required) {
|
||||
controller.set("showLogin", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
{{#if
|
||||
(and
|
||||
this.siteSettings.experimental_full_page_login
|
||||
(or this.showLogin (not this.siteSettings.login_required))
|
||||
)
|
||||
}}
|
||||
{{#if (and this.siteSettings.experimental_full_page_login (not this.welcome))}}
|
||||
{{hide-application-header-buttons "search" "login" "signup" "menu"}}
|
||||
{{hide-application-sidebar}}
|
||||
{{body-class "login-page"}}
|
||||
|
|
|
@ -850,7 +850,7 @@ class ApplicationController < ActionController::Base
|
|||
else
|
||||
# save original URL in a cookie (javascript redirects after login in this case)
|
||||
cookies[:destination_url] = destination_url
|
||||
redirect_to path("/login")
|
||||
redirect_to path("/login?welcome")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -123,6 +123,15 @@ shared_examples "login scenarios" do |login_page_object|
|
|||
login_form.fill(username: "john", password: "supersecurepassword").click_login
|
||||
expect(page).to have_css(".header-dropdown-toggle.current-user")
|
||||
end
|
||||
|
||||
it "shows login form when visiting /login route directly" do
|
||||
skip "Only applies on full page login" if !SiteSetting.experimental_full_page_login
|
||||
|
||||
visit "/login"
|
||||
|
||||
expect(page).to have_css("#login-account-name")
|
||||
expect(page).to have_css("#login-form")
|
||||
end
|
||||
end
|
||||
|
||||
context "with two-factor authentication" do
|
||||
|
|
Loading…
Reference in New Issue