TokenFromLink

tcmts.share.TokenFromLink · #varbp7da · term · runs in the browser

uses location

A token in the address's fragment (the link tcm contribute prints) signs the browser in, and leaves the address.

import { refresh } from "#codebase/tcmts/react";
import { signIn } from "#codebase/tcmts/share";
import { useEffect } from "react";

export function TokenFromLink() {
  useEffect(() => {
    const token = new URLSearchParams(location.hash.slice(1)).get("token");
    if (!token) return;
    history.replaceState(null, "", location.pathname + location.search);
    void signIn(token).then(
      () => refresh(),
      () => {},
    );
  }, []);
  return null;
}

uses

used by