From e49a1d284b320921d51d1b5224eef31f0772cec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 30 Aug 2026 22:11:32 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(members):=20a=20forgotten=20?= =?UTF-8?q?password=20was=20the=20end=20of=20the=20account?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no password reset in İzlek. The admin's resend button was the only way to put somebody back into a workspace, and it was drawn only while `!member.has_password` — so the one person who needs a fresh link, the one who forgot theirs, was the one person it was hidden from. An invited member who set a password and lost it had no way in and nobody who could give them one. `resend_invitation` never carried that restriction: it mints a link for any member of the workspace, and redeeming one sets a new password. Only the view decided otherwise, from a condition about whether the account had ever been used rather than about whether an admin may act. It now shows on every row — "Send a sign-in link" where the account has a password, "Resend mail" where it was never opened — except your own, since your password is in Your profile and mailing yourself a link is a longer way to the same pane. The test sends a link to a member who already has a password, redeems it, and signs in with the new one, so the whole way back is what is under test rather than the presence of a button. --- crates/izlek-core/src/auth.rs | 11 ++++++ crates/izlek-web/src/i18n.rs | 3 ++ crates/izlek-web/src/settings.rs | 28 ++++++++++++--- crates/izlek-web/tests/http.rs | 62 ++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 5 deletions(-) diff --git a/crates/izlek-core/src/auth.rs b/crates/izlek-core/src/auth.rs index 7abe465..f18c7e7 100644 --- a/crates/izlek-core/src/auth.rs +++ b/crates/izlek-core/src/auth.rs @@ -187,6 +187,17 @@ pub fn check_password( mod tests { use super::*; + /// The exact report: an invited member typed `abcde*abcde` and was told it + /// looked like his address or his name. It is eleven characters and shares + /// nothing with either. + #[test] + fn a_password_sharing_nothing_with_the_person_is_accepted() { + assert_eq!( + check_password("abcde*abcde", "burakboduroglu0@gmail.com", "Burak Boduroğlu"), + Ok(()) + ); + } + #[test] fn a_password_round_trips_and_a_wrong_one_does_not() { let phc = hash_password("correct horse battery").unwrap(); diff --git a/crates/izlek-web/src/i18n.rs b/crates/izlek-web/src/i18n.rs index 3e615d6..3649499 100644 --- a/crates/izlek-web/src/i18n.rs +++ b/crates/izlek-web/src/i18n.rs @@ -155,6 +155,7 @@ pub enum Key { ActiveStatus, You, ResendMail, + SendSigninLink, RoleMemberOption, RoleViewerOption, RoleAdminOption, @@ -592,6 +593,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str { (You, Tr) => "sen", (ResendMail, En) => "Resend mail", (ResendMail, Tr) => "Postayı yeniden gönder", + (SendSigninLink, En) => "Send a sign-in link", + (SendSigninLink, Tr) => "Giriş bağlantısı gönder", (RoleMemberOption, En) => "Member", (RoleMemberOption, Tr) => "Üye", (RoleViewerOption, En) => "Viewer", diff --git a/crates/izlek-web/src/settings.rs b/crates/izlek-web/src/settings.rs index b80e2da..66a04b4 100644 --- a/crates/izlek-web/src/settings.rs +++ b/crates/izlek-web/src/settings.rs @@ -1583,11 +1583,29 @@ async fn settings_page(cx: &Cx) -> Result { (account) - if !member.has_password { -
- - -
+ // The control is here for everyone an admin could + // send a link to, which is everyone. It used to be + // drawn only for a member who had never set a + // password — so the one person who needs a fresh + // link, the one who forgot theirs, was the one + // person the button was hidden from, and the + // workspace had no way back in for them at all. + // `resend_invitation` never cared: it mints a link + // for any member of this workspace. Not for + // yourself: your own password is in Your profile, + // and mailing yourself a link to it is a longer + // way round to the same pane. + if !member.is_you { +
+ + +
}
diff --git a/crates/izlek-web/tests/http.rs b/crates/izlek-web/tests/http.rs index 54e9e0a..d82038e 100644 --- a/crates/izlek-web/tests/http.rs +++ b/crates/izlek-web/tests/http.rs @@ -536,6 +536,68 @@ async fn queued_join_token(app: &App, email: &str) -> String { } /// Invites someone in the given role and signs them in, returning their cookie. +#[tokio::test] +async fn an_admin_can_send_a_signin_link_to_somebody_who_already_has_a_password() { + // Somebody who forgets their password is the person who needs a fresh + // link, and they were the one person the button was hidden from: it was + // drawn only while `!has_password`. There was no other way back into the + // workspace — no reset anywhere — so a forgotten password was the end of + // that account. + let app = App::open().await; + let admin_cookie = admin(&app).await; + // `invited` redeems the link, so this member has a password. + let _member = invited(&app, &admin_cookie, "emre@izlek.sh", "Emre", Role::Member).await; + + let page = app.get("/settings?section=members", Some(&admin_cookie)).await; + let page = String::from_utf8_lossy(&page.bytes); + assert!( + page.contains("Send a sign-in link"), + "no way to send a link to a member who has a password: {page}" + ); + + // And the link it sends actually works: a new password, set on the + // strength of it. + let workspace_id = app.workspace_id().await; + let member_id = app + .store + .user_by_email(&workspace_id, "emre@izlek.sh") + .await + .unwrap() + .expect("the member is not in the store") + .id; + let answer = app + .post( + "/api/resend_link", + Some(&admin_cookie), + &[("user_id", &member_id)], + ) + .await; + assert_eq!(answer.status, StatusCode::SEE_OTHER, "{}", answer.body); + + let token = queued_join_token(&app, "emre@izlek.sh").await; + let answer = app + .post( + "/api/redeem_link", + None, + &[("token", &token), ("password", "second thoughts about oats")], + ) + .await; + assert_eq!(answer.status, StatusCode::SEE_OTHER, "{}", answer.body); + assert_eq!(answer.body, "null", "the reissued link was refused"); + + let back = app + .post( + "/api/sign_in", + None, + &[ + ("email", "emre@izlek.sh"), + ("password", "second thoughts about oats"), + ], + ) + .await; + assert!(back.session.is_some(), "the new password does not sign in: {}", back.body); +} + #[tokio::test] async fn a_password_may_be_made_of_punctuation() { // An invited member reported "it would not accept the *". Nothing in the