diff --git a/crates/in-web/src/i18n.rs b/crates/in-web/src/i18n.rs
index 5b693c1..83e471f 100644
--- a/crates/in-web/src/i18n.rs
+++ b/crates/in-web/src/i18n.rs
@@ -238,6 +238,7 @@ pub enum Key {
// Re-viewable share links (LinkVisible owns this block).
Shared,
LegacyLinkNote,
+ RemintLink,
}
pub fn t(lang: Lang, key: Key) -> &'static str {
@@ -403,6 +404,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
LegacyLinkNote => {
"This link predates re-viewable addresses — revoke and mint a new one to carry it forward."
}
+ RemintLink => "Mint a new link",
},
Lang::Tr => match key {
Cancel => "Vazgeç",
@@ -566,6 +568,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
LegacyLinkNote => {
"Bu bağlantı, adreslerin yeniden görüntülenebildiği dönemden önce oluşturuldu — devam ettirmek için iptal edip yeni bir tane oluşturun."
}
+ RemintLink => "Yeni bağlantı oluştur",
},
}
}
diff --git a/crates/in-web/src/settings.rs b/crates/in-web/src/settings.rs
index d666619..a586cc1 100644
--- a/crates/in-web/src/settings.rs
+++ b/crates/in-web/src/settings.rs
@@ -472,7 +472,7 @@ async fn settings(cx: &Cx) -> Result {
// The same affordance the modal's live row
// carries: the full address with its copy
- // button, or the masked value plus the
+ // button, or the one-click mint plus the
// carry-forward note for a link from before
// the sealing.
if url.is_none() {
diff --git a/crates/in-web/src/share.rs b/crates/in-web/src/share.rs
index b44cbd2..fd91294 100644
--- a/crates/in-web/src/share.rs
+++ b/crates/in-web/src/share.rs
@@ -1,6 +1,7 @@
//! Sharing: public links, per-user grants, and the shared-with-me page.
//!
-//! `POST /api/share/link/create|revoke` mints and kills bearer links over a
+//! `POST /api/share/link/create|revoke|remint` mints, kills, and re-mints
+//! bearer links over a
//! file or folder (`can_download`, optional expiry in days; only the token
//! hash is stored). `POST /api/share/user/add|remove` grants and revokes
//! named users the same way. `GET /s/{token}` is public — no auth —
@@ -373,6 +374,108 @@ async fn revoke_link(cx: &Cx, Form(input): Form) -> Redirect {
}
}
+/// Carries a legacy link forward: a fresh mint over the same target, with
+/// the old row's `can_download`, its password, and a still-future expiry —
+/// an elapsed one drops, since a minted expiry opens for no one. Only its
+/// creator may; a foreign or unknown link is answered as if it never
+/// existed. The old row and its sealed setting die with the mint, the
+/// revoke path's exact semantics: the address remint replaces was already
+/// unrecoverable.
+#[route(POST "/api/share/link/remint")]
+async fn remint_link(cx: &Cx, Form(input): Form) -> Redirect {
+ let user = match require_user(cx).await {
+ Ok(user) => user,
+ Err(refusal) => {
+ return redirect_back(cx, "/settings?section=links", "remint", Some(refusal));
+ }
+ };
+ let store = app(cx).store;
+ let mine = store
+ .share_links(&user.id)
+ .await
+ .map_err(|_| Refusal::Unavailable);
+ let Ok(links) = mine else {
+ return redirect_back(
+ cx,
+ "/settings?section=links",
+ "remint",
+ Some(Refusal::Unavailable),
+ );
+ };
+ let Some(old) = links
+ .iter()
+ .find(|link| link.id == input.id && link.created_by == user.id)
+ else {
+ return redirect_back(
+ cx,
+ "/settings?section=links",
+ "remint",
+ Some(Refusal::NotFound),
+ );
+ };
+ // A still-future expiry carries over; an elapsed one would mint a link
+ // that is dead on arrival.
+ let expires_at = old.expires_at.filter(|at| *at > OffsetDateTime::now_utc());
+ let created = store
+ .create_share_link(
+ &user.id,
+ old.kind.clone(),
+ &old.target_id,
+ old.can_download,
+ expires_at,
+ old.password_hash.clone(),
+ )
+ .await;
+ match created {
+ Ok(minted) => match store.revoke_share_link(&input.id).await {
+ Ok(()) => {
+ // The sealed address dies with the link — part of the
+ // remint, not cleanup after it, so a failed delete reports
+ // the remint as refused.
+ match store
+ .delete_setting(&format!("share_token:{}", input.id))
+ .await
+ {
+ Ok(()) => {
+ // The fresh token gets the seal, exactly as a
+ // creation seals its own; a failed seal is lived
+ // with, because the redirect below shows the full
+ // address regardless.
+ let sealed =
+ in_core::store::secret::seal(&app(cx).link_key, &minted.token);
+ let _ = app(cx)
+ .store
+ .set_setting(&format!("share_token:{}", minted.link.id), &sealed)
+ .await;
+ let back = back_to(cx, "/settings?section=links");
+ let separator = if back.contains('?') { '&' } else { '?' };
+ let location = format!("{back}{separator}created={}", minted.token);
+ Ok((StatusCode::SEE_OTHER, [(header::LOCATION, location)]))
+ }
+ Err(error) => redirect_back(
+ cx,
+ "/settings?section=links",
+ "remint",
+ Some(refusal_of(error)),
+ ),
+ }
+ }
+ Err(error) => redirect_back(
+ cx,
+ "/settings?section=links",
+ "remint",
+ Some(refusal_of(error)),
+ ),
+ },
+ Err(error) => redirect_back(
+ cx,
+ "/settings?section=links",
+ "remint",
+ Some(refusal_of(error)),
+ ),
+ }
+}
+
/// Whether `at` is the link's target or sits under it: every step up must be
/// live, owned by the link's owner, and end at the target. A break anywhere
/// means the browse is outside the share.
@@ -1520,10 +1623,17 @@ pub(crate) async fn share_modal(
// leaves the typed-address field in place below.
let default_quota = app(cx).config.default_quota_bytes;
let mut candidates: Vec = Vec::new();
- if let Some(members) = in_client::directory(cx).await {
+ if let Ok(members) = app(cx).directory.directory().await {
for member in members {
let row = store
- .provision_user(&member.sub, &member.email, &member.name, default_quota)
+ .provision_user(
+ &member.sub,
+ &member.email,
+ &member.name,
+ Some(member.admin),
+ member.photo_version,
+ default_quota,
+ )
.await?;
if !row.disabled
&& row.id != user.id
@@ -1629,9 +1739,9 @@ pub(crate) async fn share_modal(
}
for link in live.iter().take(1) {
- // The full address, re-derived from the token the creation sealed
// away. A link from before the sealing — or one whose key is gone —
- // keeps the masked value and carries the carry-forward note.
+ // has no address to re-show: the row carries the mint action and the
+ // note below states the fact.
let url = share_link_url(cx, *link).await;
let legacy = url.is_none();