change in confirm mechanism
This commit is contained in:
@@ -344,6 +344,11 @@ export async function handleAccountConfirmationToken() {
|
||||
const token = mailActionToken("/auth/confirm", "confirm_token");
|
||||
if (!token) return false;
|
||||
clearMailActionUrl();
|
||||
const confirmed = await askConfirm(
|
||||
"Confirm activation of this RustPad account.",
|
||||
{ title: "Confirm account", confirmText: "Activate account" },
|
||||
);
|
||||
if (!confirmed) return true;
|
||||
try {
|
||||
const result = await api("/api/auth/confirm-account", { method: "POST", body: JSON.stringify({ token }) });
|
||||
await showMessage(result.message, { title: "Account confirmed" });
|
||||
@@ -378,6 +383,25 @@ export async function handleResetToken() {
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function handleShareInvitationToken() {
|
||||
const token = mailActionToken("/share-invitations", "share_invitation_token");
|
||||
if (!token || !location.pathname.endsWith("/accept")) return false;
|
||||
clearMailActionUrl();
|
||||
|
||||
const confirmed = await askConfirm(
|
||||
"Accept this sharing invitation?",
|
||||
{ title: "Sharing invitation", confirmText: "Accept invitation" },
|
||||
);
|
||||
if (!confirmed) return true;
|
||||
try {
|
||||
const result = await api(`/share-invitations/${encodeURIComponent(token)}/accept`, { method: "POST" });
|
||||
window.location.assign(result.url);
|
||||
} catch (error) {
|
||||
await showMessage(error.message, { title: "Invitation failed" });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function handleAccountActionToken() {
|
||||
const token = mailActionToken("/auth/account-action", "account_action_token");
|
||||
if (!token) return false;
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import { installGlobalDiagnostics, logInfo } from "@rustpad/logger";
|
||||
installGlobalDiagnostics();
|
||||
|
||||
import { bindIdentityDialog, handleAccountActionToken, handleAccountConfirmationToken, handleResetToken, logoutCurrentSession, validateCurrentSession } from "@rustpad/auth-ui";
|
||||
import { bindIdentityDialog, handleAccountActionToken, handleAccountConfirmationToken, handleResetToken, handleShareInvitationToken, logoutCurrentSession, validateCurrentSession } from "@rustpad/auth-ui";
|
||||
import { getAuthToken, setAccessToken } from "@rustpad/session";
|
||||
import { api } from "@rustpad/api";
|
||||
import { copyText } from "@rustpad/clipboard";
|
||||
@@ -83,7 +83,7 @@ document.querySelector("#workspace-form").addEventListener("submit", async (even
|
||||
}
|
||||
});
|
||||
|
||||
await handleAccountConfirmationToken() || await handleResetToken() || await handleAccountActionToken();
|
||||
await handleAccountConfirmationToken() || await handleResetToken() || await handleAccountActionToken() || await handleShareInvitationToken();
|
||||
|
||||
const identityDialog = document.querySelector("#identity-dialog");
|
||||
const guestAccount = document.querySelector("#footer-account-guest");
|
||||
|
||||
Reference in New Issue
Block a user