mirror of
https://github.com/element-hq/matrix-authentication-service.git
synced 2026-10-23 23:54:14 +00:00
Import the CAPTCHA component only from base.html on the registration page
The page imported it on its own as well, which is what broke the CAPTCHA rendering fixed by #5992 on the old password registration page. Also test that the page renders with a CAPTCHA configured.
This commit is contained in:
1 parent
96a0eb2c82
commit
00a6a06762
3 files changed
+38
-13
No files matched your search
@@ -260,9 +260,9 @@ mod tests {
|
||||
use hyper::{Request, StatusCode, header::LOCATION};
|
||||
use mas_axum_utils::csrf::CsrfExt as _;
|
||||
use mas_data_model::{
|
||||
Clock, UlidExt, UpstreamOAuthProviderClaimsImports, UpstreamOAuthProviderDiscoveryMode,
|
||||
UpstreamOAuthProviderOnBackchannelLogout, UpstreamOAuthProviderPkceMode,
|
||||
UpstreamOAuthProviderTokenAuthMethod,
|
||||
CaptchaConfig, CaptchaService, Clock, UlidExt, UpstreamOAuthProviderClaimsImports,
|
||||
UpstreamOAuthProviderDiscoveryMode, UpstreamOAuthProviderOnBackchannelLogout,
|
||||
UpstreamOAuthProviderPkceMode, UpstreamOAuthProviderTokenAuthMethod,
|
||||
};
|
||||
use mas_iana::jose::JsonWebSignatureAlg;
|
||||
use mas_storage::{
|
||||
@@ -384,6 +384,32 @@ mod tests {
|
||||
assert!(body.contains(r#"name="password_confirm""#));
|
||||
}
|
||||
|
||||
/// The page renders with a CAPTCHA configured
|
||||
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
|
||||
async fn test_get_with_captcha(pool: PgPool) {
|
||||
setup();
|
||||
let state = TestState::from_pool_with_site_config(
|
||||
pool,
|
||||
SiteConfig {
|
||||
captcha: Some(CaptchaConfig {
|
||||
service: CaptchaService::HCaptcha,
|
||||
site_key: "site-key".to_owned(),
|
||||
secret_key: "secret-key".to_owned(),
|
||||
}),
|
||||
..test_site_config()
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let cookies = CookieHelper::new();
|
||||
|
||||
let (_csrf_token, body) = render_page(&state, &cookies).await;
|
||||
assert!(
|
||||
body.contains(r#"data-captcha-site-key="site-key""#),
|
||||
"response body: {body}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Without password registration, the page is just the provider buttons
|
||||
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
|
||||
async fn test_get_password_disabled_with_providers(pool: PgPool) {
|
||||
|
||||
@@ -10,7 +10,6 @@ Please see LICENSE files in the repository root for full details.
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% from "components/idp_brand.html" import logo %}
|
||||
{% import "components/captcha.html" as captcha %}
|
||||
|
||||
{% block content %}
|
||||
<header class="page-heading">
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
},
|
||||
"continue": "Continue",
|
||||
"@continue": {
|
||||
"context": "form_post.html:26:28-48, pages/consent.html:71:28-48, pages/device_link.html:54:28-48, pages/login.html:68:30-50, pages/reauth.html:32:28-48, pages/recovery/start.html:38:26-46, pages/register/index.html:84:28-48, pages/register/steps/display_name.html:43:28-48, pages/register/steps/registration_token.html:41:28-48, pages/register/steps/verify_email.html:51:26-46, pages/sso.html:52:28-48"
|
||||
"context": "form_post.html:26:28-48, pages/consent.html:71:28-48, pages/device_link.html:54:28-48, pages/login.html:68:30-50, pages/reauth.html:32:28-48, pages/recovery/start.html:38:26-46, pages/register/index.html:83:28-48, pages/register/steps/display_name.html:43:28-48, pages/register/steps/registration_token.html:41:28-48, pages/register/steps/verify_email.html:51:26-46, pages/sso.html:52:28-48"
|
||||
},
|
||||
"create_account": "Create Account",
|
||||
"@create_account": {
|
||||
@@ -79,7 +79,7 @@
|
||||
},
|
||||
"email_address": "Email address",
|
||||
"@email_address": {
|
||||
"context": "pages/recovery/start.html:34:33-58, pages/register/index.html:48:37-62, pages/upstream_oauth2/do_register.html:115:37-62"
|
||||
"context": "pages/recovery/start.html:34:33-58, pages/register/index.html:47:37-62, pages/upstream_oauth2/do_register.html:115:37-62"
|
||||
},
|
||||
"loading": "Loading…",
|
||||
"@loading": {
|
||||
@@ -91,15 +91,15 @@
|
||||
},
|
||||
"password": "Password",
|
||||
"@password": {
|
||||
"context": "pages/login.html:56:37-57, pages/reauth.html:28:35-55, pages/register/index.html:53:35-55"
|
||||
"context": "pages/login.html:56:37-57, pages/reauth.html:28:35-55, pages/register/index.html:52:35-55"
|
||||
},
|
||||
"password_confirm": "Confirm password",
|
||||
"@password_confirm": {
|
||||
"context": "pages/register/index.html:57:35-63"
|
||||
"context": "pages/register/index.html:56:35-63"
|
||||
},
|
||||
"username": "Username",
|
||||
"@username": {
|
||||
"context": "pages/login.html:51:39-59, pages/register/index.html:39:35-55, pages/upstream_oauth2/do_register.html:101:35-55, pages/upstream_oauth2/do_register.html:107:39-59"
|
||||
"context": "pages/login.html:51:39-59, pages/register/index.html:38:35-55, pages/upstream_oauth2/do_register.html:101:35-55, pages/upstream_oauth2/do_register.html:107:39-59"
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
@@ -461,7 +461,7 @@
|
||||
},
|
||||
"continue_with_provider": "Continue with %(provider)s",
|
||||
"@continue_with_provider": {
|
||||
"context": "pages/login.html:81:15-67, pages/register/index.html:96:11-63",
|
||||
"context": "pages/login.html:81:15-67, pages/register/index.html:95:11-63",
|
||||
"description": "Button to log in with an upstream provider"
|
||||
},
|
||||
"description": "Please sign in to continue:",
|
||||
@@ -688,18 +688,18 @@
|
||||
"register": {
|
||||
"call_to_login": "Already have an account?",
|
||||
"@call_to_login": {
|
||||
"context": "pages/register/index.html:101:33-64",
|
||||
"context": "pages/register/index.html:100:33-64",
|
||||
"description": "Displayed on the registration page to suggest to log in instead"
|
||||
},
|
||||
"create_account": {
|
||||
"heading": "Create an account",
|
||||
"@heading": {
|
||||
"context": "pages/register/index.html:22:27-67"
|
||||
"context": "pages/register/index.html:21:27-67"
|
||||
}
|
||||
},
|
||||
"terms_of_service": "I agree to the <a href=\"%s\" data-kind=\"primary\" class=\"cpd-link\">Terms and Conditions</a>",
|
||||
"@terms_of_service": {
|
||||
"context": "pages/register/index.html:62:37-97, pages/upstream_oauth2/do_register.html:180:35-95"
|
||||
"context": "pages/register/index.html:61:37-97, pages/upstream_oauth2/do_register.html:180:35-95"
|
||||
}
|
||||
},
|
||||
"registration_token": {
|
||||
|
||||
Reference in new issue
Block a user