From b4485201d50eff67144da3d0200a27f82640ab29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Mon, 11 Apr 2022 19:23:51 +0200 Subject: [PATCH] Invite siasky.net users to recover their account on skynetfree.net --- .../src/components/Form/SelfServiceForm.js | 12 +++++++++++- packages/dashboard/src/pages/auth/recovery.js | 15 +++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/packages/dashboard/src/components/Form/SelfServiceForm.js b/packages/dashboard/src/components/Form/SelfServiceForm.js index b4d086ad..e0df6ec2 100644 --- a/packages/dashboard/src/components/Form/SelfServiceForm.js +++ b/packages/dashboard/src/components/Form/SelfServiceForm.js @@ -3,7 +3,14 @@ import { useFormik, getIn, setIn } from "formik"; import classnames from "classnames"; import SelfServiceMessages from "./SelfServiceMessages"; -export default function SelfServiceForm({ fieldsConfig, onSubmit, title, validationSchema = null, button = "Submit" }) { +export default function SelfServiceForm({ + fieldsConfig, + onSubmit, + title, + onError, + validationSchema = null, + button = "Submit", +}) { const [messages, setMessages] = React.useState([]); const fields = fieldsConfig.sort((a, b) => (a.position < b.position ? -1 : 1)); const formik = useFormik({ @@ -21,6 +28,9 @@ export default function SelfServiceForm({ fieldsConfig, onSubmit, title, validat const data = await error.response.json(); if (data.message) { + if (typeof onError === "function") { + onError(data.message); + } setMessages((messages) => [...messages, { type: "error", text: data.message }]); } } else { diff --git a/packages/dashboard/src/pages/auth/recovery.js b/packages/dashboard/src/pages/auth/recovery.js index 05f94d85..14ee5778 100644 --- a/packages/dashboard/src/pages/auth/recovery.js +++ b/packages/dashboard/src/pages/auth/recovery.js @@ -23,6 +23,8 @@ export default function Recovery() { useAnonRoute(); // ensure user is not logged in const [success, setSuccess] = React.useState(false); + const [skynetFreeInviteVisible, setSkynetFreeInviteVisible] = React.useState(false); + const isSiaskyNet = typeof window !== "undefined" && window.location.hostname === "account.siasky.net"; const onSubmit = async (values) => { await accountsApi.post("user/recover/request", { @@ -64,6 +66,16 @@ export default function Recovery() { {" "} for a new account

+ {skynetFreeInviteVisible && isSiaskyNet && ( +
+

+ All Siasky.net accounts have been moved to{" "} + + SkynetFree.net + +

+
+ )} {!success && ( @@ -72,6 +84,9 @@ export default function Recovery() { validationSchema={validationSchema} onSubmit={onSubmit} button="Send recovery link" + onError={(errorMessage) => + setSkynetFreeInviteVisible(errorMessage === "registrations are currently disabled") + } /> )}