diff --git a/packages/api/src/errors.js b/packages/api/src/errors.js index 3458703967..0672eca40c 100644 --- a/packages/api/src/errors.js +++ b/packages/api/src/errors.js @@ -284,3 +284,27 @@ export class ErrorAgentDIDRequired extends HTTPError { } } ErrorAgentDIDRequired.CODE = 'ERROR_AGENT_DID_REQUIRED' + +/** + * Error indicating a new user signup was denied and probably will be indefinitely, + * and the user should try a new product instead. + */ +export class NewUserDeniedTryOtherProductError extends HTTPError { + /** + * @param {string} message + * @param {URL} otherProduct + */ + constructor(message, otherProduct) { + super(message, 403) + this.code = 'NEW_USER_DENIED_TRY_OTHER_PRODUCT' + this.otherProduct = otherProduct + } + + toJSON() { + return { + message: this.message, + code: this.code, + otherProduct: this.otherProduct.toString(), + } + } +} diff --git a/packages/api/src/utils/auth.js b/packages/api/src/utils/auth.js index 70f753cc74..70a9e7ae0f 100644 --- a/packages/api/src/utils/auth.js +++ b/packages/api/src/utils/auth.js @@ -7,6 +7,7 @@ import { ErrorUnauthenticated, ErrorTokenBlocked, ErrorAgentDIDRequired, + NewUserDeniedTryOtherProductError, } from '../errors.js' import { parseJWT, verifyJWT } from './jwt.js' import * as Ucan from 'ucan-storage/ucan-storage' @@ -137,6 +138,18 @@ export async function loginOrRegister(event, data, { db }) { ? await parseGithub(data.data, metadata) : parseMagic(metadata) + const dbUser = + data.type === 'github' + ? await db.getUser(parsed.sub) + : await db.getUser(parsed.issuer) + if (!dbUser) { + const otherProduct = new URL('https://nft.storage/') + throw new NewUserDeniedTryOtherProductError( + `We're no longer accepting new accounts for NFT.Storage Classic. Learn more about our new experience>> ${otherProduct.toString()}`, + otherProduct + ) + } + const upsert = await db.upsertUser({ email: parsed.email, github_id: parsed.sub, diff --git a/packages/website/components/deprecationBanner.js b/packages/website/components/deprecationBanner.js new file mode 100644 index 0000000000..200b86b109 --- /dev/null +++ b/packages/website/components/deprecationBanner.js @@ -0,0 +1,10 @@ +export function DeprecationBanner() { + return ( +
+ We're evolving our platform for you. Learn more >>  + + https://nft.storage/blog/the-next-chapter-of-nftstorage + +
+ ) +} diff --git a/packages/website/components/footer.js b/packages/website/components/footer.js index 07fdec4053..1e293df342 100644 --- a/packages/website/components/footer.js +++ b/packages/website/components/footer.js @@ -105,6 +105,16 @@ export default function Footer() { + + + Privacy + + + Need Help? { let bannerMessage = '' @@ -133,6 +134,7 @@ export default function Layout({ ) : ( <> +
{children({ user })}