From 1033995801f4a274dba9c9e041da82cfd52e38f9 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sat, 18 Sep 2021 19:43:08 -0400 Subject: [PATCH 1/3] Set a 10 char minimum password length. --- crates/api_common/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/api_common/src/lib.rs b/crates/api_common/src/lib.rs index a79e842ee..1e57ffa70 100644 --- a/crates/api_common/src/lib.rs +++ b/crates/api_common/src/lib.rs @@ -426,7 +426,8 @@ pub async fn build_federated_instances( /// Checks the password length pub fn password_length_check(pass: &str) -> Result<(), LemmyError> { - if pass.len() > 60 { + let password_length = pass.len(); + if !(10..=60).contains(&password_length) { Err(ApiError::err("invalid_password").into()) } else { Ok(()) From 721962589c7a36b030a8c73a5aa705e60fdb8d7d Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sat, 18 Sep 2021 19:53:30 -0400 Subject: [PATCH 2/3] Clean up. --- crates/api_common/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/api_common/src/lib.rs b/crates/api_common/src/lib.rs index 1e57ffa70..933a096c5 100644 --- a/crates/api_common/src/lib.rs +++ b/crates/api_common/src/lib.rs @@ -426,8 +426,7 @@ pub async fn build_federated_instances( /// Checks the password length pub fn password_length_check(pass: &str) -> Result<(), LemmyError> { - let password_length = pass.len(); - if !(10..=60).contains(&password_length) { + if !(10..=60).contains(&pass.len()) { Err(ApiError::err("invalid_password").into()) } else { Ok(()) From 0fbc342fe3dce2049dc4e0584fa1790f4b91fa14 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sun, 19 Sep 2021 17:20:47 -0400 Subject: [PATCH 3/3] Fix tests --- api_tests/src/shared.ts | 16 +++++++++------- docker/federation/lemmy_alpha.hjson | 2 +- docker/federation/lemmy_beta.hjson | 2 +- docker/federation/lemmy_delta.hjson | 2 +- docker/federation/lemmy_epsilon.hjson | 2 +- docker/federation/lemmy_gamma.hjson | 2 +- docker/lemmy.hjson | 2 +- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/api_tests/src/shared.ts b/api_tests/src/shared.ts index 1a1f9a5c3..8c7a79331 100644 --- a/api_tests/src/shared.ts +++ b/api_tests/src/shared.ts @@ -76,34 +76,36 @@ export let epsilon: API = { client: new LemmyHttp('http://localhost:8581'), }; +const password = 'lemmylemmy' + export async function setupLogins() { let formAlpha: Login = { username_or_email: 'lemmy_alpha', - password: 'lemmy', + password, }; let resAlpha = alpha.client.login(formAlpha); let formBeta = { username_or_email: 'lemmy_beta', - password: 'lemmy', + password, }; let resBeta = beta.client.login(formBeta); let formGamma = { username_or_email: 'lemmy_gamma', - password: 'lemmy', + password, }; let resGamma = gamma.client.login(formGamma); let formDelta = { username_or_email: 'lemmy_delta', - password: 'lemmy', + password, }; let resDelta = delta.client.login(formDelta); let formEpsilon = { username_or_email: 'lemmy_epsilon', - password: 'lemmy', + password, }; let resEpsilon = epsilon.client.login(formEpsilon); @@ -510,8 +512,8 @@ export async function registerUser( ): Promise { let form: Register = { username, - password: 'test', - password_verify: 'test', + password, + password_verify: password, show_nsfw: true, }; return api.client.register(form); diff --git a/docker/federation/lemmy_alpha.hjson b/docker/federation/lemmy_alpha.hjson index cb38aa8b6..3795f0d79 100644 --- a/docker/federation/lemmy_alpha.hjson +++ b/docker/federation/lemmy_alpha.hjson @@ -5,7 +5,7 @@ jwt_secret: changeme setup: { admin_username: lemmy_alpha - admin_password: lemmy + admin_password: lemmylemmy site_name: lemmy-alpha sidebar: alphas sidebar } diff --git a/docker/federation/lemmy_beta.hjson b/docker/federation/lemmy_beta.hjson index e16ecd53b..1c0b3876b 100644 --- a/docker/federation/lemmy_beta.hjson +++ b/docker/federation/lemmy_beta.hjson @@ -5,7 +5,7 @@ jwt_secret: changeme setup: { admin_username: lemmy_beta - admin_password: lemmy + admin_password: lemmylemmy site_name: lemmy-beta } database: { diff --git a/docker/federation/lemmy_delta.hjson b/docker/federation/lemmy_delta.hjson index 321775fb5..2f7dfecb4 100644 --- a/docker/federation/lemmy_delta.hjson +++ b/docker/federation/lemmy_delta.hjson @@ -5,7 +5,7 @@ jwt_secret: changeme setup: { admin_username: lemmy_delta - admin_password: lemmy + admin_password: lemmylemmy site_name: lemmy-delta } database: { diff --git a/docker/federation/lemmy_epsilon.hjson b/docker/federation/lemmy_epsilon.hjson index 20fb2c353..87d142a8f 100644 --- a/docker/federation/lemmy_epsilon.hjson +++ b/docker/federation/lemmy_epsilon.hjson @@ -5,7 +5,7 @@ jwt_secret: changeme setup: { admin_username: lemmy_epsilon - admin_password: lemmy + admin_password: lemmylemmy site_name: lemmy-epsilon } database: { diff --git a/docker/federation/lemmy_gamma.hjson b/docker/federation/lemmy_gamma.hjson index 784f98eb7..2b94a968d 100644 --- a/docker/federation/lemmy_gamma.hjson +++ b/docker/federation/lemmy_gamma.hjson @@ -5,7 +5,7 @@ jwt_secret: changeme setup: { admin_username: lemmy_gamma - admin_password: lemmy + admin_password: lemmylemmy site_name: lemmy-gamma } database: { diff --git a/docker/lemmy.hjson b/docker/lemmy.hjson index 53f0ff170..de7cf68a0 100644 --- a/docker/lemmy.hjson +++ b/docker/lemmy.hjson @@ -6,7 +6,7 @@ # username for the admin user admin_username: "lemmy" # password for the admin user - admin_password: "lemmy" + admin_password: "lemmylemmy" # name of the site (can be changed later) site_name: "lemmy-test" }