on master help sign in
Get ticket from url #hash on invite activation page
1b600f8Fang
src/lib/useImpliedTicket.jsnew file+14
@@ -0,0 +1,14 @@
1+import * as ob from 'urbit-ob';
2+
3+import { prependSig } from './transformers';
4+
5+/**
6+ * pull the suggested ticket from the #hash in the url
7+ */
8+export default function useImpliedTicket() {
9+ const hash = window.location.hash.slice(1);
10+ const tick = prependSig(hash);
11+ const isValid = ob.isValidPatq(tick);
12+
13+ return isValid ? tick : null;
14+}
src/views/Activate/ActivateCode.js+3
@@ -21,11 +21,13 @@ import { generateWallet } from 'lib/invite';
21import { generateTemporaryOwnershipWallet } from 'lib/walletgen';
21import { generateTemporaryOwnershipWallet } from 'lib/walletgen';
22import { useActivateFlow } from './ActivateFlow';
22import { useActivateFlow } from './ActivateFlow';
23import { useLocalRouter } from 'lib/LocalRouter';
23import { useLocalRouter } from 'lib/LocalRouter';
24+import useImpliedTicket from 'lib/useImpliedTicket';
24
25
25export default function ActivateCode() {
26export default function ActivateCode() {
26 const history = useHistory();
27 const history = useHistory();
27 const { names, push } = useLocalRouter();
28 const { names, push } = useLocalRouter();
28 const { contracts } = useNetwork();
29 const { contracts } = useNetwork();
30+ const impliedTicket = useImpliedTicket();
29 const [generalError, setGeneralError] = useState();
31 const [generalError, setGeneralError] = useState();
30 const [deriving, setDeriving] = useState(false);
32 const [deriving, setDeriving] = useState(false);
31 const {
33 const {
@@ -39,6 +41,7 @@ export default function ActivateCode() {
39 const [ticketInput, { pass: validTicket }] = useTicketInput({
41 const [ticketInput, { pass: validTicket }] = useTicketInput({
40 name: 'ticket',
42 name: 'ticket',
41 label: 'Code',
43 label: 'Code',
44+ initialValue: impliedTicket || '',
42 autoFocus: true,
45 autoFocus: true,
43 });
46 });
44
47