FIX: Discourse Connect fixes for full page login (#29915)
This commit is contained in:
parent
5e734516db
commit
a964e62cd8
|
@ -116,8 +116,15 @@ export default class LoginPageController extends Controller {
|
||||||
return getURL("/u/admin-login");
|
return getURL("/u/admin-login");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get shouldTriggerRouteAction() {
|
||||||
|
return (
|
||||||
|
!this.siteSettings.experimental_full_page_login ||
|
||||||
|
this.siteSettings.enable_discourse_connect
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
showLoginPage() {
|
showFullPageLogin() {
|
||||||
this.showLogin = true;
|
this.showLogin = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,12 +54,6 @@ export default class SignupPageController extends Controller.extend(
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fetchConfirmationValue();
|
this.fetchConfirmationValue();
|
||||||
|
|
||||||
if (this.skipConfirmation) {
|
|
||||||
this.performAccountCreation().finally(() =>
|
|
||||||
this.set("skipConfirmation", false)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@bind
|
@bind
|
||||||
|
@ -342,6 +336,14 @@ export default class SignupPageController extends Controller.extend(
|
||||||
return this._hpPromise;
|
return this._hpPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleSkipConfirmation() {
|
||||||
|
if (this.skipConfirmation) {
|
||||||
|
this.performAccountCreation().finally(() =>
|
||||||
|
this.set("skipConfirmation", false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
performAccountCreation() {
|
performAccountCreation() {
|
||||||
if (
|
if (
|
||||||
!this._challengeDate ||
|
!this._challengeDate ||
|
||||||
|
|
|
@ -146,6 +146,7 @@ export default {
|
||||||
Object.keys(createAccountProps || {}).forEach((key) => {
|
Object.keys(createAccountProps || {}).forEach((key) => {
|
||||||
signupController.set(key, createAccountProps[key]);
|
signupController.set(key, createAccountProps[key]);
|
||||||
});
|
});
|
||||||
|
signupController.handleSkipConfirmation();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
modal.show(CreateAccount, { model: createAccountProps });
|
modal.show(CreateAccount, { model: createAccountProps });
|
||||||
|
|
|
@ -11,7 +11,8 @@ export default class LoginRoute extends DiscourseRoute {
|
||||||
beforeModel() {
|
beforeModel() {
|
||||||
if (
|
if (
|
||||||
!this.siteSettings.login_required &&
|
!this.siteSettings.login_required &&
|
||||||
!this.siteSettings.experimental_full_page_login
|
(!this.siteSettings.experimental_full_page_login ||
|
||||||
|
this.siteSettings.enable_discourse_connect)
|
||||||
) {
|
) {
|
||||||
this.router
|
this.router
|
||||||
.replaceWith(`/${defaultHomepage()}`)
|
.replaceWith(`/${defaultHomepage()}`)
|
||||||
|
|
|
@ -161,9 +161,9 @@
|
||||||
|
|
||||||
<DButton
|
<DButton
|
||||||
@action={{if
|
@action={{if
|
||||||
this.siteSettings.experimental_full_page_login
|
this.shouldTriggerRouteAction
|
||||||
this.showLoginPage
|
|
||||||
(route-action "showLogin")
|
(route-action "showLogin")
|
||||||
|
this.showFullPageLogin
|
||||||
}}
|
}}
|
||||||
@icon="user"
|
@icon="user"
|
||||||
@label="log_in"
|
@label="log_in"
|
||||||
|
|
|
@ -98,6 +98,18 @@ module PageObjects
|
||||||
has_valid_password?
|
has_valid_password?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def has_disabled_email?
|
||||||
|
find(".create-account-email").has_css?("input[disabled]")
|
||||||
|
end
|
||||||
|
|
||||||
|
def has_disabled_name?
|
||||||
|
find(".create-account__fullname").has_css?("input[disabled]")
|
||||||
|
end
|
||||||
|
|
||||||
|
def has_disabled_username?
|
||||||
|
find(".create-account__username").has_css?("input[disabled]")
|
||||||
|
end
|
||||||
|
|
||||||
def click_social_button(provider)
|
def click_social_button(provider)
|
||||||
click(".btn-social.#{provider}")
|
click(".btn-social.#{provider}")
|
||||||
end
|
end
|
||||||
|
|
|
@ -98,6 +98,18 @@ module PageObjects
|
||||||
has_valid_password?
|
has_valid_password?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def has_disabled_email?
|
||||||
|
find(".create-account-email").has_css?("input[disabled]")
|
||||||
|
end
|
||||||
|
|
||||||
|
def has_disabled_name?
|
||||||
|
find(".create-account__fullname").has_css?("input[disabled]")
|
||||||
|
end
|
||||||
|
|
||||||
|
def has_disabled_username?
|
||||||
|
find(".create-account__username").has_css?("input[disabled]")
|
||||||
|
end
|
||||||
|
|
||||||
def click_social_button(provider)
|
def click_social_button(provider)
|
||||||
click(".btn-social.#{provider}")
|
click(".btn-social.#{provider}")
|
||||||
end
|
end
|
||||||
|
|
|
@ -171,6 +171,67 @@ shared_examples "social authentication scenarios" do |signup_page_object, login_
|
||||||
expect(page).to have_css(".header-dropdown-toggle.current-user")
|
expect(page).to have_css(".header-dropdown-toggle.current-user")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# These tests use Google, but they should be the same for all providers
|
||||||
|
|
||||||
|
context "when opening the external auth from /login" do
|
||||||
|
before { SiteSetting.enable_google_oauth2_logins = true }
|
||||||
|
after { reset_omniauth_config(:google_oauth2) }
|
||||||
|
|
||||||
|
it "fills the signup form" do
|
||||||
|
mock_google_auth
|
||||||
|
visit("/")
|
||||||
|
|
||||||
|
signup_form.open.click_social_button("google_oauth2")
|
||||||
|
expect(signup_form).to be_open
|
||||||
|
expect(signup_form).to have_no_password_input
|
||||||
|
expect(signup_form).to have_valid_username
|
||||||
|
expect(signup_form).to have_valid_email
|
||||||
|
signup_form.click_create_account
|
||||||
|
expect(page).to have_css(".header-dropdown-toggle.current-user")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when overriding local fields" do
|
||||||
|
before do
|
||||||
|
SiteSetting.enable_google_oauth2_logins = true
|
||||||
|
SiteSetting.auth_overrides_name = true
|
||||||
|
SiteSetting.auth_overrides_username = true
|
||||||
|
end
|
||||||
|
after { reset_omniauth_config(:google_oauth2) }
|
||||||
|
|
||||||
|
it "fills the signup form and disables the inputs" do
|
||||||
|
mock_google_auth
|
||||||
|
visit("/")
|
||||||
|
|
||||||
|
signup_form.open.click_social_button("google_oauth2")
|
||||||
|
expect(signup_form).to be_open
|
||||||
|
expect(signup_form).to have_no_password_input
|
||||||
|
expect(signup_form).to have_valid_username
|
||||||
|
expect(signup_form).to have_valid_email
|
||||||
|
expect(signup_form).to have_disabled_username
|
||||||
|
expect(signup_form).to have_disabled_email
|
||||||
|
expect(signup_form).to have_disabled_name
|
||||||
|
signup_form.click_create_account
|
||||||
|
expect(page).to have_css(".header-dropdown-toggle.current-user")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when skipping the signup form" do
|
||||||
|
before do
|
||||||
|
SiteSetting.enable_google_oauth2_logins = true
|
||||||
|
SiteSetting.auth_skip_create_confirm = true
|
||||||
|
end
|
||||||
|
after { reset_omniauth_config(:google_oauth2) }
|
||||||
|
|
||||||
|
it "creates the account directly" do
|
||||||
|
mock_google_auth
|
||||||
|
visit("/")
|
||||||
|
|
||||||
|
signup_form.open.click_social_button("google_oauth2")
|
||||||
|
expect(page).to have_css(".header-dropdown-toggle.current-user")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when user exists" do
|
context "when user exists" do
|
||||||
|
|
Loading…
Reference in New Issue