Skip to content

Commit

Permalink
Merge branch 'main' into utm-templates
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-tey authored Oct 14, 2024
2 parents e5e0927 + a22f981 commit 2508dc2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
10 changes: 10 additions & 0 deletions apps/web/app/api/auth/reset-password/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ export async function POST(req: NextRequest) {

const { identifier } = tokenFound;

const user = await prisma.user.findUniqueOrThrow({
where: {
email: identifier,
},
select: {
emailVerified: true,
},
});

await prisma.$transaction([
// Delete the token
prisma.passwordResetToken.deleteMany({
Expand All @@ -56,6 +65,7 @@ export async function POST(req: NextRequest) {
data: {
passwordHash: await hashPassword(password),
lockedAt: null, // Unlock the account after a successful password reset
...(!user.emailVerified && { emailVerified: new Date() }), // Mark the email as verified
},
}),
]);
Expand Down
10 changes: 2 additions & 8 deletions apps/web/app/app.dub.co/(auth)/login/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const errorCodes = {
"exceeded-login-attempts":
"Account has been locked due to too many login attempts. Please contact support to unlock your account.",
"too-many-login-attempts": "Too many login attempts. Please try again later.",
"email-not-verified": "Please verify your email address.",
};

const LoginFormContext = createContext<{
Expand Down Expand Up @@ -388,20 +389,13 @@ const SignInWithEmail = () => {

// Handle errors
if (!res.ok && res.error) {
if (res.error === "email-not-verified") {
router.push(
`/register/verify-email?email=${encodeURIComponent(email)}`,
);
return;
}

if (errorCodes[res.error]) {
toast.error(errorCodes[res.error]);
} else {
toast.error(res.error);
}
setClickedMethod(undefined);

setClickedMethod(undefined);
return;
}

Expand Down
1 change: 0 additions & 1 deletion apps/web/lib/middleware/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default async function AppMiddleware(req: NextRequest) {
path !== "/login" &&
path !== "/forgot-password" &&
path !== "/register" &&
path !== "/register/verify-email" &&
path !== "/auth/saml" &&
!path.startsWith("/auth/reset-password/")
) {
Expand Down
5 changes: 4 additions & 1 deletion apps/web/ui/layout/sidebar/usage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,7 @@ function UsageRow({
const formatNumber = (value: number) =>
value >= 1000000000
? "∞"
: nFormatter(value, { full: value !== undefined && value < 9999 });
: nFormatter(value, {
full: value !== undefined && value < 9999,
digits: 1,
});

0 comments on commit 2508dc2

Please sign in to comment.