Skip to content

Commit d0965ae

Browse files
author
Boopathi
committed
Update login modal and main view components
1 parent 03e4da6 commit d0965ae

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

src/components/auth/login-modal.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export default function LoginModal({ isOpen, setIsOpen, onLoginSuccess }: LoginM
7070
title: "Admin Login Successful",
7171
description: "Welcome, Admin!",
7272
});
73-
setIsOpen(false);
73+
setIsOpen(false);
7474
onLoginSuccess({
7575
role: "admin",
7676
token: "dev-admin-token",
@@ -196,24 +196,33 @@ export default function LoginModal({ isOpen, setIsOpen, onLoginSuccess }: LoginM
196196
return;
197197
}
198198

199+
const actionCodeSettings = {
200+
url: `${window.location.origin}/?action=login&from=reset`,
201+
handleCodeInApp: true,
202+
};
203+
199204
try {
200-
await sendPasswordResetEmail(auth, email);
205+
await sendPasswordResetEmail(auth, email, actionCodeSettings);
201206
toast({
202207
title: "Password Reset Email Sent",
203-
description: "Please check your inbox for instructions to reset your password.",
208+
description: "Please check your inbox for instructions to reset your password. You will be redirected back here.",
204209
});
205210
} catch (error: any) {
211+
let description = "Could not send password reset email. Please check the address and try again.";
212+
if (error.code === 'auth/user-not-found') {
213+
description = "No user found with this email address."
214+
}
206215
toast({
207216
variant: "destructive",
208217
title: "Failed to Send Email",
209-
description: "Could not send password reset email. Please check the address and try again.",
218+
description: description,
210219
});
211220
}
212221
};
213222

214223
return (
215224
<Dialog open={isOpen} onOpenChange={setIsOpen}>
216-
<DialogContent className="sm:max-w-lg">
225+
<DialogContent className="sm:max-w-lg auth-modal-glow overflow-hidden">
217226
<DialogHeader className="text-center">
218227
<DialogTitle>Login</DialogTitle>
219228
<DialogDescription>

src/components/views/main-view.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
"use client";
23

34
import { useState, useEffect, useCallback } from "react";
@@ -88,7 +89,24 @@ export default function MainView() {
8889

8990
useEffect(() => {
9091
const error = searchParams.get('error');
91-
const status = searchParams.get('status');
92+
const from = searchParams.get('from');
93+
const action = searchParams.get('action');
94+
95+
if (action === 'login' && from === 'verification') {
96+
toast({
97+
title: "Verification Successful!",
98+
description: "Your email has been verified. Please log in to continue.",
99+
});
100+
setActiveView('login');
101+
router.replace('/');
102+
} else if (action === 'login' && from === 'reset') {
103+
toast({
104+
title: "Password Reset Successful",
105+
description: "Please log in with your new password.",
106+
});
107+
setActiveView('login');
108+
router.replace('/');
109+
}
92110

93111
if (status === 'pending_approval') {
94112
toast({
@@ -347,4 +365,4 @@ export default function MainView() {
347365
/>}
348366
</>
349367
);
350-
}
368+
}

0 commit comments

Comments
 (0)