forge
Explore
Log in

Don't you dare go Hollow

A forgotten password was the end of the account

Browse files at this commit

e49a1d284b320921d51d1b5224eef31f0772cec3Ahmet Kaan GümüşParent: 78c0728
  • fix
    • a forgotten password was the end of the account
Show full message
🐛 fix(members): a forgotten password was the end of the account

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.rsmodified+11 -0
@@ -187,6 +187,17 @@ pub fn check_password(
187 mod tests {187 mod tests {
188 use super::*;188 use super::*;
189 189
190+ /// The exact report: an invited member typed `abcde*abcde` and was told it
191+ /// looked like his address or his name. It is eleven characters and shares
192+ /// nothing with either.
193+ #[test]
194+ fn a_password_sharing_nothing_with_the_person_is_accepted() {
195+ assert_eq!(
196+ check_password("abcde*abcde", "burakboduroglu0@gmail.com", "Burak Boduroğlu"),
197+ Ok(())
198+ );
199+ }
200+
190 #[test]201 #[test]
191 fn a_password_round_trips_and_a_wrong_one_does_not() {202 fn a_password_round_trips_and_a_wrong_one_does_not() {
192 let phc = hash_password("correct horse battery").unwrap();203 let phc = hash_password("correct horse battery").unwrap();
crates/izlek-web/src/i18n.rsmodified+3 -0
@@ -155,6 +155,7 @@ pub enum Key {
155 ActiveStatus,155 ActiveStatus,
156 You,156 You,
157 ResendMail,157 ResendMail,
158+ SendSigninLink,
158 RoleMemberOption,159 RoleMemberOption,
159 RoleViewerOption,160 RoleViewerOption,
160 RoleAdminOption,161 RoleAdminOption,
@@ -592,6 +593,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
592 (You, Tr) => "sen",593 (You, Tr) => "sen",
593 (ResendMail, En) => "Resend mail",594 (ResendMail, En) => "Resend mail",
594 (ResendMail, Tr) => "Postayı yeniden gönder",595 (ResendMail, Tr) => "Postayı yeniden gönder",
596+ (SendSigninLink, En) => "Send a sign-in link",
597+ (SendSigninLink, Tr) => "Giriş bağlantısı gönder",
595 (RoleMemberOption, En) => "Member",598 (RoleMemberOption, En) => "Member",
596 (RoleMemberOption, Tr) => "Üye",599 (RoleMemberOption, Tr) => "Üye",
597 (RoleViewerOption, En) => "Viewer",600 (RoleViewerOption, En) => "Viewer",
crates/izlek-web/src/settings.rsmodified+23 -5
@@ -1583,11 +1583,29 @@ async fn settings_page(cx: &Cx) -> Result {
1583 <td class="member-col-account member-account">1583 <td class="member-col-account member-account">
1584 <span class="member-account-row">1584 <span class="member-account-row">
1585 <span class="member-status">(account)</span>1585 <span class="member-status">(account)</span>
1586- if !member.has_password {1586+ // The control is here for everyone an admin could
1587- <form method="post" action="/api/resend_link" class="member-resend">1587+ // send a link to, which is everyone. It used to be
1588- <input type="hidden" name="user_id" value=(member.id.clone())>1588+ // drawn only for a member who had never set a
1589- <button class="quiet" type="submit">(t(lang, Key::ResendMail))</button>1589+ // password — so the one person who needs a fresh
1590- </form>1590+ // link, the one who forgot theirs, was the one
1591+ // person the button was hidden from, and the
1592+ // workspace had no way back in for them at all.
1593+ // `resend_invitation` never cared: it mints a link
1594+ // for any member of this workspace. Not for
1595+ // yourself: your own password is in Your profile,
1596+ // and mailing yourself a link to it is a longer
1597+ // way round to the same pane.
1598+ if !member.is_you {
1599+ <form method="post" action="/api/resend_link" class="member-resend">
1600+ <input type="hidden" name="user_id" value=(member.id.clone())>
1601+ <button class="quiet" type="submit">
1602+ (if member.has_password {
1603+ t(lang, Key::SendSigninLink)
1604+ } else {
1605+ t(lang, Key::ResendMail)
1606+ })
1607+ </button>
1608+ </form>
1591 }1609 }
1592 </span>1610 </span>
1593 </td>1611 </td>
crates/izlek-web/tests/http.rsmodified+62 -0
@@ -536,6 +536,68 @@ async fn queued_join_token(app: &App, email: &str) -> String {
536 }536 }
537 537
538 /// Invites someone in the given role and signs them in, returning their cookie.538 /// Invites someone in the given role and signs them in, returning their cookie.
539+#[tokio::test]
540+async fn an_admin_can_send_a_signin_link_to_somebody_who_already_has_a_password() {
541+ // Somebody who forgets their password is the person who needs a fresh
542+ // link, and they were the one person the button was hidden from: it was
543+ // drawn only while `!has_password`. There was no other way back into the
544+ // workspace — no reset anywhere — so a forgotten password was the end of
545+ // that account.
546+ let app = App::open().await;
547+ let admin_cookie = admin(&app).await;
548+ // `invited` redeems the link, so this member has a password.
549+ let _member = invited(&app, &admin_cookie, "emre@izlek.sh", "Emre", Role::Member).await;
550+
551+ let page = app.get("/settings?section=members", Some(&admin_cookie)).await;
552+ let page = String::from_utf8_lossy(&page.bytes);
553+ assert!(
554+ page.contains("Send a sign-in link"),
555+ "no way to send a link to a member who has a password: {page}"
556+ );
557+
558+ // And the link it sends actually works: a new password, set on the
559+ // strength of it.
560+ let workspace_id = app.workspace_id().await;
561+ let member_id = app
562+ .store
563+ .user_by_email(&workspace_id, "emre@izlek.sh")
564+ .await
565+ .unwrap()
566+ .expect("the member is not in the store")
567+ .id;
568+ let answer = app
569+ .post(
570+ "/api/resend_link",
571+ Some(&admin_cookie),
572+ &[("user_id", &member_id)],
573+ )
574+ .await;
575+ assert_eq!(answer.status, StatusCode::SEE_OTHER, "{}", answer.body);
576+
577+ let token = queued_join_token(&app, "emre@izlek.sh").await;
578+ let answer = app
579+ .post(
580+ "/api/redeem_link",
581+ None,
582+ &[("token", &token), ("password", "second thoughts about oats")],
583+ )
584+ .await;
585+ assert_eq!(answer.status, StatusCode::SEE_OTHER, "{}", answer.body);
586+ assert_eq!(answer.body, "null", "the reissued link was refused");
587+
588+ let back = app
589+ .post(
590+ "/api/sign_in",
591+ None,
592+ &[
593+ ("email", "emre@izlek.sh"),
594+ ("password", "second thoughts about oats"),
595+ ],
596+ )
597+ .await;
598+ assert!(back.session.is_some(), "the new password does not sign in: {}", back.body);
599+}
600+
539 #[tokio::test]601 #[tokio::test]
540 async fn a_password_may_be_made_of_punctuation() {602 async fn a_password_may_be_made_of_punctuation() {
541 // An invited member reported "it would not accept the *". Nothing in the603 // An invited member reported "it would not accept the *". Nothing in the