Invite siasky.net users to recover their account on skynetfree.net

This commit is contained in:
Michał Leszczyk 2022-04-11 19:23:51 +02:00
parent d0a253c5fe
commit b4485201d5
No known key found for this signature in database
GPG Key ID: FA123CA8BAA2FBF4
2 changed files with 26 additions and 1 deletions

View File

@ -3,7 +3,14 @@ import { useFormik, getIn, setIn } from "formik";
import classnames from "classnames"; import classnames from "classnames";
import SelfServiceMessages from "./SelfServiceMessages"; 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 [messages, setMessages] = React.useState([]);
const fields = fieldsConfig.sort((a, b) => (a.position < b.position ? -1 : 1)); const fields = fieldsConfig.sort((a, b) => (a.position < b.position ? -1 : 1));
const formik = useFormik({ const formik = useFormik({
@ -21,6 +28,9 @@ export default function SelfServiceForm({ fieldsConfig, onSubmit, title, validat
const data = await error.response.json(); const data = await error.response.json();
if (data.message) { if (data.message) {
if (typeof onError === "function") {
onError(data.message);
}
setMessages((messages) => [...messages, { type: "error", text: data.message }]); setMessages((messages) => [...messages, { type: "error", text: data.message }]);
} }
} else { } else {

View File

@ -23,6 +23,8 @@ export default function Recovery() {
useAnonRoute(); // ensure user is not logged in useAnonRoute(); // ensure user is not logged in
const [success, setSuccess] = React.useState(false); 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) => { const onSubmit = async (values) => {
await accountsApi.post("user/recover/request", { await accountsApi.post("user/recover/request", {
@ -64,6 +66,16 @@ export default function Recovery() {
</Link>{" "} </Link>{" "}
for a new account for a new account
</p> </p>
{skynetFreeInviteVisible && isSiaskyNet && (
<div className="font-content rounded border border-blue-200 mt-6 p-4 bg-blue-100">
<p>
All Siasky.net accounts have been moved to{" "}
<a className="text-primary" href="https://skynetfree.net">
SkynetFree.net
</a>
</p>
</div>
)}
</div> </div>
{!success && ( {!success && (
@ -72,6 +84,9 @@ export default function Recovery() {
validationSchema={validationSchema} validationSchema={validationSchema}
onSubmit={onSubmit} onSubmit={onSubmit}
button="Send recovery link" button="Send recovery link"
onError={(errorMessage) =>
setSkynetFreeInviteVisible(errorMessage === "registrations are currently disabled")
}
/> />
)} )}