Skip to content

Commit

Permalink
move auth routes to /dashboard (#2157)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsoffer authored May 1, 2024
1 parent 307c0e1 commit 7d3d68c
Show file tree
Hide file tree
Showing 20 changed files with 1,102 additions and 28 deletions.
12 changes: 8 additions & 4 deletions packages/api/src/controllers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ app.patch("/:id/email", authorizer({}), async (req, res) => {
buttonText: "Verify Email",
buttonUrl: frontendUrl(
req,
`/verify-new-email?${qs.stringify({
`/dashboard/verify-new-email?${qs.stringify({
emailValidToken,
email: lowerCaseEmail,
})}`
Expand Down Expand Up @@ -905,7 +905,7 @@ app.post("/verify", validatePost("user-verification"), async (req, res) => {
subject: `User ${user.email} signed up with Livepeer!`,
preheader: "We have a new verified user",
buttonText: "Log into livepeer",
buttonUrl: frontendUrl(req, "/login"),
buttonUrl: frontendUrl(req, "/dashboard/login"),
unsubscribe: unsubscribeUrl(req),
text: [
`User ${user.email} has signed up and verified their email with Livepeer!`,
Expand Down Expand Up @@ -979,7 +979,11 @@ async function sendVerificationEmail(req: Request, user: User, selectedPlan) {
buttonText: "Verify Email",
buttonUrl: frontendUrl(
req,
`/verify?${qs.stringify({ email, emailValidToken, selectedPlan })}`
`/dashboard/verify?${qs.stringify({
email,
emailValidToken,
selectedPlan,
})}`
),
unsubscribe: unsubscribeUrl(req),
text: [
Expand Down Expand Up @@ -1068,7 +1072,7 @@ app.post(
buttonText: "Reset Password",
buttonUrl: frontendUrl(
req,
`/reset-password?${qs.stringify({ email, resetToken })}`
`/dashboard/reset-password?${qs.stringify({ email, resetToken })}`
),
unsubscribe: unsubscribeUrl(req),
text: [
Expand Down
2 changes: 1 addition & 1 deletion packages/www/components/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const Login = ({ id, buttonText, onSubmit, loading, errors }) => {
transform: "translateY(-50%)",
top: "50%",
}}>
<Link href="/forgot-password" passHref legacyBehavior>
<Link href="/dashboard/forgot-password" passHref legacyBehavior>
<A
variant="primary"
css={{
Expand Down
6 changes: 3 additions & 3 deletions packages/www/components/Plans/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ const Plans = ({ dashboard = false, stripeProductId }: PlanProps) => {
stripeProductId="prod_O9XuIjn7EqYRVW"
onClick={() => {
if (!dashboard) {
router.push("/register");
router.push("/dashboard/register");
}
}}
/>
Expand Down Expand Up @@ -349,7 +349,7 @@ const Plans = ({ dashboard = false, stripeProductId }: PlanProps) => {
if (dashboard) {
setIsTourOpen(false);
} else {
router.push("/register?selectedPlan=1");
router.push("/dashboard/register?selectedPlan=1");
}
}}
/>
Expand Down Expand Up @@ -511,7 +511,7 @@ const Plans = ({ dashboard = false, stripeProductId }: PlanProps) => {
if (dashboard) {
setIsTourOpen(false);
} else {
router.push("/register?selectedPlan=2");
router.push("/dashboard/register?selectedPlan=2");
}
}}
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/www/components/Site/Compare/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const CompareHero = ({
how its features and pricing compare to {comparison}.
</Text>
<Flex align="center" gap={1}>
<Link href="/register" passHref>
<Link href="/dashboard/register" passHref>
<Button
target="_blank"
size={3}
Expand Down
2 changes: 1 addition & 1 deletion packages/www/components/Site/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const Footer = () => {
Contact
</Button>
</Link>
<Link href="/login" passHref legacyBehavior>
<Link href="/dashboard/login" passHref legacyBehavior>
<Button
as={A}
small
Expand Down
2 changes: 1 addition & 1 deletion packages/www/components/Site/HomeHero/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const HomeHero = ({ backgroundColor = "$loContrast" }) => {
</small>
</Text>
<Flex align="center" css={{ justifyContent: "center" }}>
<Link href="/register" passHref>
<Link href="/dashboard/register" passHref>
<Button
size={4}
variant="green"
Expand Down
4 changes: 2 additions & 2 deletions packages/www/components/Site/Navigation/base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ const NavigationBase = ({
display: "block",
},
}}>
<Link href="/login" passHref legacyBehavior>
<Link href="/dashboard/login" passHref legacyBehavior>
<A>
<Button variant="neutral" css={{ mr: "$3" }} size={3}>
Sign in
Expand All @@ -425,7 +425,7 @@ const NavigationBase = ({
display: "block",
},
}}>
<Link href="/register" passHref legacyBehavior>
<Link href="/dashboard/register" passHref legacyBehavior>
<A>
<Button variant="green" size={3}>
Sign Up
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const AuthButtons = ({
}) => {
if (!isTokenDefined) {
return (
<Link href="/login" passHref legacyBehavior>
<Link href="/dashboard/login" passHref legacyBehavior>
<Button
onClick={() => setMobileMenuIsOpen(false)}
arrow
Expand Down
2 changes: 1 addition & 1 deletion packages/www/components/Site/Prefooter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const Prefooter = ({ backgroundColor = "inherit" }) => (
flexDirection: "row",
},
}}>
<Link href="/register">
<Link href="/dashboard/register">
<Button
size={4}
as={A}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,9 @@ const Preview = ({ transcoding, streaming }: PreviewProps) => {
size="4"
disabled={streaming + transcoding === 0}
onClick={() => {
router.push(token ? "/dashboard/billing/plans" : "/register");
router.push(
token ? "/dashboard/billing/plans" : "/dashboard/register"
);
}}>
{totalValue > 3000 ? "Contact us" : "Get Started"}
</Button>
Expand Down
2 changes: 1 addition & 1 deletion packages/www/hooks/use-logged-in.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function useLoggedIn(shouldBeLoggedIn = true) {
useEffect(() => {
if (shouldBeLoggedIn === true) {
if (!token) {
router.replace("/login");
router.replace("/dashboard/login");
} else if (emailVerificationMode && user?.emailValid === false) {
router.replace("/verify");
}
Expand Down
67 changes: 67 additions & 0 deletions packages/www/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,73 @@ let config = {
destination: "https://livepeer.canny.io",
permanent: false,
},
{
source: "/register",
destination: "/dashboard/register",
permanent: false,
},
{
source: "/login",
destination: "/dashboard/login",
permanent: false,
},
{
source: "/verify",
destination:
"/dashboard/verify?email=:email&emailValidToken=:emailValidToken&selectedPlan=:selectedPlan",
permanent: false,
has: [
{
type: "query",
key: "email",
},
{
type: "query",
key: "emailValidToken",
},
{
type: "query",
key: "selectedPlan",
},
],
},
{
source: "/verify-new-email",
destination:
"/dashboard/verify-new-email?email=:email&emailValidToken=:emailValidToken",
permanent: false,
has: [
{
type: "query",
key: "email",
},
{
type: "query",
key: "emailValidToken",
},
],
},
{
source: "/reset-password",
destination:
"/dashboard/reset-password?email=:email&resetToken=:resetToken",
permanent: false,
has: [
{
type: "query",
key: "email",
},
{
type: "query",
key: "resetToken",
},
],
},
{
source: "/forgot-password",
destination: "/dashboard/forgot-password",
permanent: false,
},
];
},
};
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Link as A,
} from "@livepeer/design-system";
import { useState } from "react";
import { useApi, useLoggedIn } from "../hooks";
import { useApi, useLoggedIn } from "../../hooks";
import Link from "next/link";
import { Home as Content } from "content";

Expand Down Expand Up @@ -85,7 +85,7 @@ const LoginPage = () => {
"linear-gradient(to right,transparent,rgba(255,255,255,0.1) 50%,transparent)",
}}
/>
<Link href="/register" passHref legacyBehavior>
<Link href="/dashboard/register" passHref legacyBehavior>
<A
css={{
"&:hover": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Layout from "layouts/main";
import { withRecaptcha } from "layouts/withRecaptcha";
import Login from "../components/Login";
import Register from "../components/Register";
import Login from "../../components/Login";
import Register from "../../components/Register";
import {
Flex,
Box,
Expand All @@ -15,7 +15,7 @@ import { useRouter } from "next/router";
import { useGoogleReCaptcha } from "react-google-recaptcha-v3";
import { Register as Content } from "content";
import Link from "next/link";
import { useApi, useLoggedIn } from "../hooks";
import { useApi, useLoggedIn } from "../../hooks";
import { useJune, events } from "hooks/use-june";

const emailVerificationMode =
Expand Down Expand Up @@ -49,7 +49,7 @@ const RegisterPage = () => {
useEffect(() => {
if (user) {
if (emailVerificationMode && user.emailValid === false) {
router.replace("/verify");
router.replace("/dashboard/verify");
} else {
router.replace("/dashboard");
}
Expand Down Expand Up @@ -143,7 +143,7 @@ const RegisterPage = () => {
"linear-gradient(to right,transparent,rgba(255,255,255,0.1) 50%,transparent)",
}}
/>
<Link href="/login" passHref legacyBehavior>
<Link href="/dashboard/login" passHref legacyBehavior>
<A
css={{
cursor: "default",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions packages/www/pages/use-cases/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const UseCase = ({
imageType="rectangle"
ctas={[
{
href: "/register",
href: "/dashboard/register",
title: "Get started",
},
{
Expand All @@ -127,7 +127,7 @@ const UseCase = ({
reasons={features.reasons}
ctas={[
{
href: "/register",
href: "/dashboard/register",
title: "Start Building",
},
{
Expand Down
Loading

0 comments on commit 7d3d68c

Please sign in to comment.